def handleIgnore(self): if base.cr.isFriend(self.avatar.doId): self.dialog = TTDialog.TTGlobalDialog( style=TTDialog.CancelOnly, text=TTLocalizer.IgnorePanelAddFriendAvatar % self.avName, text_wordwrap=18.5, text_scale=0.06, cancelButtonText=TTLocalizer.lCancel, doneEvent='IgnoreBlocked', command=self.freeLocalAvatar) else: self.dialog = TTDialog.TTGlobalDialog( style=TTDialog.TwoChoice, text=TTLocalizer.IgnorePanelAddIgnore % self.avName, text_wordwrap=18.5, text_scale=TTLocalizer.APBdialog, okButtonText=TTLocalizer.AvatarPanelIgnore, cancelButtonText=TTLocalizer.lCancel, doneEvent='IgnoreConfirm', command=self.handleIgnoreConfirm) DirectLabel(parent=self.dialog, relief=None, pos=(0, TTLocalizer.APBdirectLabelPosY, 0.125), text=TTLocalizer.IgnorePanelTitle, textMayChange=0, text_scale=0.08) self.dialog.show() self.__acceptStoppedStateMsg() self.requestStopped() return
def __handleTrueFriends(self): if not settings['trueFriends']: base.localAvatar.chatMgr.fsm.request('noTrueFriends') return self.cleanupDialog() base.cr.playGame.getPlace().fsm.request('stopped') if base.localAvatar.isTrueFriends(self.avatar.doId): self.dialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.TrueFriendsRemoveNotice % self.avatar.getName(), text_wordwrap=20, command=self.confirmTrueFriendsRemove) self.dialog.show() elif not base.cr.isFriend(self.avatar.doId): self.dialog = TTDialog.TTDialog( style=TTDialog.Acknowledge, text=TTLocalizer.TrueFriendsNotFriends % self.avatar.getName(), text_wordwrap=20, command=self.cleanupDialogAndWalk) self.dialog.show() else: self.dialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.TrueFriendsAddNotice % self.avatar.getName(), text_wordwrap=20, command=self.confirmTrueFriendsAdd) self.dialog.show()
def enterTeleportIn(self, requestStatus): reason = requestStatus.get('reason') if reason == RaceGlobals.Exit_Barrier: requestStatus['nextState'] = 'popup' self.dialog = TTDialog.TTDialog(text=TTLocalizer.KartRace_RaceTimeout, command=self.__cleanupDialog, style=TTDialog.Acknowledge) elif reason == RaceGlobals.Exit_Slow: requestStatus['nextState'] = 'popup' self.dialog = TTDialog.TTDialog(text=TTLocalizer.KartRace_RacerTooSlow, command=self.__cleanupDialog, style=TTDialog.Acknowledge) elif reason == RaceGlobals.Exit_BarrierNoRefund: requestStatus['nextState'] = 'popup' self.dialog = TTDialog.TTDialog(text=TTLocalizer.KartRace_RaceTimeoutNoRefund, command=self.__cleanupDialog, style=TTDialog.Acknowledge) Playground.Playground.enterTeleportIn(self, requestStatus)
def handlePicking(self): messenger.send('wakeup') fullName = GardenGlobals.getFlowerVarietyName(self.species, self.variety) if self.isWilted(): self.confirmDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.ConfirmWiltedFlower % {'plant': fullName}, command=self.confirmCallback) elif not self.isFruiting(): self.confirmDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.ConfirmUnbloomingFlower % {'plant': fullName}, command=self.confirmCallback) elif base.localAvatar.isFlowerBasketFull(): self.confirmDialog = TTDialog.TTDialog( style=TTDialog.CancelOnly, text=TTLocalizer.ConfirmBasketFull, command=self.confirmCallback) else: shovel = base.localAvatar.shovel skill = base.localAvatar.shovelSkill shovelPower = GardenGlobals.getShovelPower(shovel, skill) giveSkillUp = True beansRequired = GardenGlobals.getNumBeansRequired( self.species, self.variety) if not shovelPower == beansRequired: giveSkillUp = False if giveSkillUp: if skill == GardenGlobals.getMaxShovelSkill(): text = (TTLocalizer.ConfirmMaxedSkillFlower % { 'plant': fullName }, ) else: text = TTLocalizer.ConfirmSkillupFlower % { 'plant': fullName } self.confirmDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=text, command=self.confirmCallback) else: self.confirmDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.ConfirmNoSkillupFlower % {'plant': fullName}, command=self.confirmCallback) self.confirmDialog.show() base.localAvatar.setInGardenAction(self) base.cr.playGame.getPlace().detectedGardenPlotUse()
def setMovie(self, mode, avId, timestamp): self.notify.debug('setMovie(mode=%s, avId=%s, timestamp=%s)' % (mode, avId, timestamp)) timeStamp = globalClockDelta.localElapsedTime(timestamp) isLocalToon = avId == base.localAvatar.doId self.notify.info( 'setMovie: mode=%s, avId=%s, timeStamp=%s, isLocalToon=%s' % (mode, avId, timeStamp, isLocalToon)) if mode == BANK_MOVIE_CLEAR: self.notify.debug('setMovie: clear') elif mode == BANK_MOVIE_GUI: self.notify.debug('setMovie: gui') track = Sequence() track.append(Func(self.__takeOutToonJar, avId)) if isLocalToon: track.append(Wait(3.0)) track.append(Func(self.showBankGui)) track.start() self.bankTrack = track elif mode == BANK_MOVIE_DEPOSIT: self.notify.debug('setMovie: deposit') self.__putAwayToonJar(avId) elif mode == BANK_MOVIE_WITHDRAW: self.notify.debug('setMovie: withdraw') self.__putAwayToonJar(avId) elif mode == BANK_MOVIE_NO_OP: self.notify.debug('setMovie: no op') self.__putAwayToonJar(avId) elif mode == BANK_MOVIE_NOT_OWNER: self.notify.debug('setMovie: not owner') if isLocalToon: self.bankDialog = TTDialog.TTDialog( dialogName='BankNotOwner', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedBankNotOwner, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog) elif mode == BANK_MOVIE_NO_OWNER: self.notify.debug('setMovie: no owner') if isLocalToon: self.bankDialog = TTDialog.TTDialog( dialogName='BankNoOwner', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedBankNoOwner, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog) else: self.notify.warning('unknown mode in setMovie: %s' % mode)
def unload(self): self.parentFSM.getStateNamed('playground').removeChild(self.fsm) del self.parentFSM del self.fsm if self.dialog: self.dialog.cleanup() self.dialog = None if self.deathAckBox: self.deathAckBox.cleanup() self.deathAckBox = None TTDialog.cleanupDialog('globalDialog') self.ignoreAll() Place.Place.unload(self) return
def unload(self): self.parentFSM.getStateNamed('playground').removeChild(self.fsm) del self.parentFSM del self.fsm if self.dialog: self.dialog.cleanup() self.dialog = None if self.deathAckBox: self.deathAckBox.cleanup() self.deathAckBox = None TTDialog.cleanupDialog('globalDialog') self.ignoreAll() Place.Place.unload(self) return
def setMovie(self, mode, avId): isLocalToon = avId == base.localAvatar.doId if isLocalToon: DistributedMailbox.notify.debug('setMovie( mode=%d, avId=%d ) called on a local toon' % (mode, avId)) else: DistributedMailbox.notify.debug('setMovie( mode=%d, avId=%d ) called on a non-local toon' % (mode, avId)) if mode == MailboxGlobals.MAILBOX_MOVIE_CLEAR: DistributedMailbox.notify.debug('setMovie: clear') return elif mode == MailboxGlobals.MAILBOX_MOVIE_EXIT: if random.random() < 0.5: sfx = base.loadSfx('phase_5.5/audio/sfx/mailbox_close_1.ogg') else: sfx = base.loadSfx('phase_5.5/audio/sfx/mailbox_close_2.ogg') sfxTrack = SoundInterval(sfx, node=self.model) sfxTrack.start() DistributedMailbox.notify.debug('setMovie: exit') return elif mode == MailboxGlobals.MAILBOX_MOVIE_EMPTY: DistributedMailbox.notify.debug('setMovie: empty') if isLocalToon: self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxEmpty', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxEmpty, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog) return elif mode == MailboxGlobals.MAILBOX_MOVIE_WAITING: DistributedMailbox.notify.debug('setMovie: waiting') if isLocalToon: self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxWaiting', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxWaiting, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog) return elif mode == MailboxGlobals.MAILBOX_MOVIE_READY: DistributedMailbox.notify.debug('setMovie: ready') if random.random() < 0.5: sfx = base.loadSfx('phase_5.5/audio/sfx/mailbox_open_1.ogg') else: sfx = base.loadSfx('phase_5.5/audio/sfx/mailbox_open_2.ogg') sfxTrack = SoundInterval(sfx, node=self.model) sfxTrack.start() if isLocalToon: self.mailboxGui = MailboxScreen.MailboxScreen(self, base.localAvatar, self.mailboxGuiDoneEvent) self.mailboxGui.show() self.accept(self.mailboxGuiDoneEvent, self.__handleMailboxDone) return elif mode == MailboxGlobals.MAILBOX_MOVIE_NOT_OWNER: DistributedMailbox.notify.debug('setMovie: not owner') if isLocalToon: self.mailboxDialog = TTDialog.TTDialog(dialogName='MailboxNotOwner', style=TTDialog.Acknowledge, text=TTLocalizer.DistributedMailboxNotOwner, text_wordwrap=15, fadeScreen=1, command=self.__clearDialog) return else: DistributedMailbox.notify.warning('unknown mode in setMovie: %s' % mode)
def doResultDialog(self): self.startInteraction() curTrack, curLevel = GardenGlobals.getTreeTrackAndLevel(self.typeIndex) species = GardenGlobals.getTreeTypeIndex(curTrack, curLevel) treeName = GardenGlobals.PlantAttributes[species]['name'] stringToShow = TTLocalizer.getResultPlantedSomethingSentence(treeName) self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback)
def showMessage(self, message): self.messageDoneEvent = self.uniqueName('messageDoneEvent') self.acceptOnce(self.messageDoneEvent, self.__handleMessageDone) self.messageGui = TTDialog.TTGlobalDialog( doneEvent=self.messageDoneEvent, message=message, style=TTDialog.Acknowledge)
def shardChoiceReject(self, shardId): self.confirm = TTDialog.TTGlobalDialog( doneEvent='ShardPageConfirmDone', message=TTLocalizer.ShardPageChoiceReject, style=TTDialog.Acknowledge) self.confirm.show() self.accept('ShardPageConfirmDone', self.__handleConfirm)
def __init__(self, doneEvent): fadeModel = loader.loadModel('phase_3/models/misc/fade') if fadeModel: self.fade = DirectFrame(parent=aspect2dp, relief=None, image=fadeModel, image_color=(0, 0, 0, 0.4), image_scale=4.0, state=DGG.NORMAL) self.fade.reparentTo(aspect2d, FADE_SORT_INDEX) fadeModel.removeNode() else: print 'Problem loading fadeModel.' self.fade = None self.dialog = TTDialog.TTGlobalDialog( message=TTLocalizer.PlaygroundDeathAckMessage, doneEvent=doneEvent, style=TTDialog.Acknowledge, suppressKeys=True) self.dialog['text_pos'] = (-.26, 0.1) scale = self.dialog.component('image0').getScale() scale.setX(scale[0] * 1.3) self.dialog.component('image0').setScale(scale) av = base.localAvatar self.laffMeter = LaffMeter.LaffMeter(av.style, av.hp, av.maxHp) self.laffMeter.reparentTo(self.dialog) if av.style.getAnimal() == 'monkey': self.laffMeter.setPos(-0.46, 0, -0.035) self.laffMeter.setScale(0.085) else: self.laffMeter.setPos(-0.48, 0, -0.035) self.laffMeter.setScale(0.1) self.laffMeter.start() self.dialog.show() return
def __applyDone(self, command): self.applyDialog.cleanup() self.applyDialog = None self.setBin('gui-popup', 0) base.transitions.fadeScreen(0.5) if command != DGG.DIALOG_OK: return self.origPipe = base.pipe self.origProperties = base.win.getProperties() pipe = self.apiPipes[self.apiMenu.selectedIndex] properties = WindowProperties() xSize, ySize = self.screenSizes[self.screenSizeIndex] properties.setSize(xSize, ySize) properties.setFullscreen(self.displayMode == self.FullscreenMode) fullscreen = self.displayMode == self.FullscreenMode if not self.changeDisplayProperties(pipe, xSize, ySize, fullscreen): self.__revertBack(1) return self.clearBin() self.timeoutDialog = TTDialog.TTDialog( dialogName='DisplaySettingsTimeout', style=TTDialog.TwoChoice, text=TTLocalizer.DisplaySettingsAccept % self.ApplyTimeoutSeconds, text_wordwrap=15, command=self.__timeoutDone) self.timeoutDialog.setBin('gui-popup', 0) self.timeoutRemaining = self.ApplyTimeoutSeconds self.timeoutStart = None taskMgr.add(self.__timeoutCountdown, self.TimeoutCountdownTask)
def confirmReport(self): if base.cr.isFriend(self.avId): string = TTLocalizer.ReportPanelBodyFriends titlePos = 0.41 else: string = TTLocalizer.ReportPanelBody titlePos = 0.35 self.dialog = TTDialog.TTGlobalDialog( style=TTDialog.TwoChoice, text=string % self.avName, text_wordwrap=18.5, text_scale=0.06, okButtonText=TTLocalizer.AvatarPanelReport, cancelButtonText=TTLocalizer.lCancel, doneEvent='ReportConfirm', command=self.handleReportConfirm) DirectLabel(parent=self.dialog, relief=None, pos=(0, 0, titlePos), text=TTLocalizer.ReportPanelTitle, textMayChange=0, text_scale=0.08) self.dialog.show() self.__acceptStoppedStateMsg() self.requestStopped() return
def issueSummons(self, summonsType): if summonsType == 'building' or summonsType == 'cogdo': text = TTLocalizer.SummonDlgBuildingConf elif summonsType == 'invasion': text = TTLocalizer.SummonDlgInvasionConf elif summonsType == 'skelinvasion': text = TTLocalizer.SummonDlgSkelInvasionConf elif summonsType == 'waiterinvasion': text = TTLocalizer.SummonDlgWaiterInvasionConf elif summonsType == 'v2invasion': text = TTLocalizer.SummonDlgV2InvasionConf text = text % self.suitFullName def handleResponse(resp): self.popup.cleanup() self.popup = None self.reparentTo(self.getParent(), NO_FADE_SORT_INDEX) base.transitions.fadeScreen(0.5) if resp == DGG.DIALOG_OK: self.notify.info('issuing %s summons for %s' % (summonsType, self.suitIndex)) self.accept('cog-summons-response', self.cogSummonsDone) self.summonsType = summonsType self.doIssueSummonsText() base.localAvatar.d_reqCogSummons(self.summonsType, self.suitIndex) self.hideSummonButtons() self.cancel['state'] = DGG.DISABLED return self.reparentTo(self.getParent(), 0) self.popup = TTDialog.TTDialog(parent=aspect2dp, style=TTDialog.YesNo, text=text, fadeScreen=1, command=handleResponse)
def doResultDialog(self): self.startInteraction() itemName = GardenGlobals.PlantAttributes[self.typeIndex]['name'] stringToShow = TTLocalizer.getResultPlantedSomethingSentence(itemName) self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback)
def exitOSX(self): self.confirm = TTDialog.TTGlobalDialog( doneEvent='confirmDone', message=TTLocalizer.OptionsPageExitConfirm, style=TTDialog.TwoChoice) self.confirm.show() self.accept('confirmDone', self.handleConfirm)
def acceptItem(self, mailbox, index, callback): self.confirmRent = TTDialog.TTGlobalDialog( doneEvent='confirmRent', message=TTLocalizer.MessageConfirmRent, command=Functor(self.handleRentConfirm, mailbox, index, callback), style=TTDialog.TwoChoice) self.confirmRent.show()
def joinGroup(self, groupId, buttonTuple): self.acceptOnce('confJoin', self.confirmJoinGroup, extraArgs=[groupId, buttonTuple]) self.joinDialog = TTDialog.TTGlobalDialog( message='Would you like to join this group?', doneEvent='confJoin', style=4)
def leaveGroup(self, groupId, buttonTuple): self.acceptOnce('confLeave', self.confirmLeaveGroup, extraArgs=[groupId, buttonTuple]) self.joinDialog = TTDialog.TTGlobalDialog( message='Are you sure you want to leave this group?', doneEvent='confLeave', style=4)
def __handleDelete(self): cleanupDialog('globalDialog') self.verify = TTDialog.TTGlobalDialog( doneEvent='verifyDone', message=TTLocalizer.AvatarChoiceDeleteConfirm % self.name, style=TTDialog.TwoChoice) self.verify.show() self.accept('verifyDone', self.__handleVerifyDelete)
def enterTrolleyTFA(self): self.noTrolleyBox = TTDialog.TTGlobalDialog( message=TTLocalizer.TrolleyTFAMessage, doneEvent='noTrolleyAck', style=TTDialog.Acknowledge) self.noTrolleyBox.show() base.localAvatar.b_setAnimState('neutral', 1) self.accept('noTrolleyAck', self.__handleNoTrolleyAck)
def showMessage(self, message, endState='walk'): base.cr.playGame.getPlace().fsm.request('activity') self.acceptOnce(self.messageDoneEvent, self.__handleMessageDone) self.messageGui = TTDialog.TTGlobalDialog( doneEvent=self.messageDoneEvent, message=message, style=TTDialog.Acknowledge) self.messageGui.endState = endState
def handleKick(self): if not base.cr.playGame.getPlace().getState() == 'elevator': self.confirmKickOutDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.BoardingKickOutConfirm % self.avName, command=self.__confirmKickOutCallback) self.confirmKickOutDialog.show() localAvatar.disableAvatarControls()
def __handleLeaveButton(self): messenger.send('wakeup') if not base.cr.playGame.getPlace().getState() == 'elevator': self.confirmQuitDialog = TTDialog.TTDialog( style=TTDialog.YesNo, text=TTLocalizer.QuitBoardingPartyConfirm, command=self.__confirmQuitCallback) self.confirmQuitDialog.show()
def __handleExit(self): if self.numAtticAccepted == 0: self.__acceptExit() elif self.numAtticAccepted == 1: self.dialogBox = TTDialog.TTDialog( style=TTDialog.Acknowledge, text=TTLocalizer.CatalogAcceptInAttic, text_wordwrap=15, command=self.__acceptExit) self.dialogBox.show() else: self.dialogBox = TTDialog.TTDialog( style=TTDialog.Acknowledge, text=TTLocalizer.CatalogAcceptInAtticP, text_wordwrap=15, command=self.__acceptExit) self.dialogBox.show()
def __acceptItemCallback(self, retcode, item, index): needtoUpdate = 0 if self.acceptingIndex == None: needtoUpdate = 1 if not hasattr(self, 'frame'): return if retcode == ToontownGlobals.P_UserCancelled: print 'mailbox screen user canceled' self.acceptingIndex = None self.__updateItems() return if self.acceptingIndex != index: self.notify.warning( 'Got unexpected callback for index %s, expected %s.' % (index, self.acceptingIndex)) return self.acceptingIndex = None if retcode < 0: self.notify.info('Could not take item %s: retcode %s' % (item, retcode)) self.dialogBox = TTDialog.TTDialog( style=TTDialog.TwoChoiceCustom, text=item.getAcceptItemErrorText(retcode), text_wordwrap=15, command=self.__handleDiscard, buttonText=[ TTLocalizer.MailboxDiscard, TTLocalizer.MailboxLeave ]) self.dialogBox.show() elif hasattr(item, 'storedInAttic') and item.storedInAttic(): self.numAtticAccepted += 1 self.itemIndex += 1 if needtoUpdate == 1: self.__updateItems() else: if isinstance(item, InviteInfoBase): self.__updateItems() callback = self.__incIndexRemoveDialog self.dialogBox = TTDialog.TTDialog( style=TTDialog.Acknowledge, text=item.getAcceptItemErrorText(retcode), text_wordwrap=15, command=callback) self.dialogBox.show() return
def enterFLA(self, requestStatus): FactoryInterior.notify.info('enterFLA') self.flaDialog = TTDialog.TTGlobalDialog(message=TTLocalizer.ForcedLeaveFactoryAckMsg, doneEvent='FLADone', style=TTDialog.Acknowledge, fadeScreen=1) def continueExit(self = self, requestStatus = requestStatus): self.__processLeaveRequest(requestStatus) self.accept('FLADone', continueExit) self.flaDialog.show()
def doResultDialog(self): self.startInteraction() flowerName = GardenGlobals.getFlowerVarietyName( self.species, self.variety) stringToShow = TTLocalizer.getResultPlantedSomethingSentence( flowerName) self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback)
def __handleCastDialog(self): self.cleanupDialog() base.cr.playGame.getPlace().setState('stopped') self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.AvatarPanelCastInfo % self.avatar.getName(), text_wordwrap=20, command=self.cleanupDialogAndWalk) self.dialog.show()
def handleReadInfo(self, task=None): self.boardingInfoButton['state'] = DGG.DISABLED if self.boardingInfoText: self.boardingInfoText.destroy() self.boardingInfoText = TTDialog.TTDialog( style=TTDialog.Acknowledge, text=TTLocalizer.BoardingPartyInform % localAvatar.boardingParty.maxSize, command=self.handleCloseInfo)