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 alreadyReported(self): self.dialog = TTDialog.TTGlobalDialog(style = TTDialog.Acknowledge, text = TTLocalizer.ReportPanelAlreadyReported % self.avName, text_wordwrap = 18.5, text_scale = 0.059999999999999998, topPad = 0.10000000000000001, doneEvent = 'AlreadyReported', command = self.handleAlreadyReported) DirectLabel(parent = self.dialog, relief = None, pos = (0, 0, 0.20000000000000001), text = TTLocalizer.ReportPanelTitle, textMayChange = 0, text_scale = 0.080000000000000002) self.dialog.show() self._AvatarPanelBase__acceptStoppedStateMsg() self.requestStopped()
def enterRejectedState(self): self.notify.debug('enterRejectedState') self.rejectedDialog = TTDialog.TTGlobalDialog(doneEvent='rejectedDone', message=TTLocalizer.NameShopNameRejected, style=TTDialog.Acknowledge) self.rejectedDialog.show() self.acceptOnce('rejectedDone', self.__handleRejected)
def promptTutorial(self): self.promptTutorialDialog = TTDialog.TTDialog(parent=aspect2dp, text=TTLocalizer.PromptTutorial, text_scale=0.06, text_align=TextNode.ACenter, text_wordwrap=22, command=self.__openTutorialDialog, fadeScreen=0.5, style=TTDialog.TwoChoice, buttonTextList=[TTLocalizer.MakeAToonEnterTutorial, TTLocalizer.MakeAToonSkipTutorial], button_text_scale=0.06, buttonPadSF=5.5, sortOrder=DGG.NO_FADE_SORT_INDEX) self.promptTutorialDialog.show()
def announceGenerate(self): DistributedNPCToonBase.announceGenerate(self) self.planPartyQuestionGuiDoneEvent = 'planPartyQuestionDone' self.askGui = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('askGui'), doneEvent=self.planPartyQuestionGuiDoneEvent, message=TTLocalizer.PartyDoYouWantToPlan, style=TTDialog.YesNo, okButtonText=OTPLocalizer.DialogYes, cancelButtonText=OTPLocalizer.DialogNo) self.askGui.hide()
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 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 __makeGui(self): if base.config.GetBool('want-qa-regression', 0): self.notify.info('QA-REGRESSION: FISHING: ZoneId: %s' % self.pond.getArea()) if self.madeGui: return self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.castGui = loader.loadModel('phase_4/models/gui/fishingGui') self.castGui.setBin("background", 10) self.castGui.setScale(0.67) self.castGui.setPos(0, 1, 0) for nodeName in ('bucket', 'jar', 'display_bucket', 'display_jar'): self.castGui.find('**/' + nodeName).reparentTo(self.castGui) self.exitButton = DirectButton( parent=base.a2dBottomRight, relief=None, text=('', TTLocalizer.FishingExit, TTLocalizer.FishingExit), text_align=TextNode.ACenter, text_scale=0.1, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0.0, -0.12), pos=(-0.218, 0, 0.11), scale=0.8, textMayChange=0, image=(self.castGui.find('**/exit_buttonUp'), self.castGui.find('**/exit_buttonDown'), self.castGui.find('**/exit_buttonRollover')), command=self.__userExit) self.castGui.find('**/exitButton').removeNode() self.castButton = DirectButton( parent=self.castGui, relief=None, text=TTLocalizer.FishingCast, text_align=TextNode.ACenter, text_scale=(3, 3 * 0.75, 3 * 0.75), text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -4), image=self.castGui.find('**/castButton'), image0_color=(1, 0, 0, 1), image1_color=(0, 1, 0, 1), image2_color=(1, 1, 0, 1), image3_color=(0.8, 0.5, 0.5, 1), pos=(0, -0.05, -0.666), scale=(0.036, 1, 0.048)) self.castGui.find('**/castButton').removeNode() self.arrow = self.castGui.find('**/arrow') self.arrowTip = self.arrow.find('**/arrowTip') self.arrowTail = self.arrow.find('**/arrowTail') self.arrow.reparentTo(self.castGui) self.arrow.setColorScale(0.9, 0.9, 0.1, 0.7) self.arrow.hide() self.jar = DirectLabel(parent=self.castGui, relief=None, text=str(self.av.getMoney()), text_scale=0.16, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont(), pos=(-1.12, 0, -1.3)) self.bucket = DirectLabel(parent=self.castGui, relief=None, text='', text_scale=0.09, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), pos=(1.14, 0, -1.33)) self.__updateFishTankGui() self.itemGui = NodePath('itemGui') self.itemFrame = DirectFrame( parent=self.itemGui, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1, 1, 0.6), text=TTLocalizer.FishingItemFound, text_pos=(0, 0.2), text_scale=0.08, pos=(0, 0, 0.587)) self.itemLabel = DirectLabel(parent=self.itemFrame, text='', text_scale=0.06, pos=(0, 0, -0.25)) buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') self.itemGuiCloseButton = DirectButton( parent=self.itemFrame, pos=(0.44, 0, -0.24), relief=None, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), image_scale=(0.7, 1, 0.7), command=self.__itemGuiClose) buttons.removeNode() jarGui = loader.loadModel('phase_3.5/models/gui/jar_gui') bootGui = loader.loadModel('phase_4/models/gui/fishing_boot') packageGui = loader.loadModel( 'phase_3.5/models/gui/stickerbook_gui').find('**/package') self.itemJellybean = DirectFrame(parent=self.itemFrame, relief=None, image=jarGui, scale=0.5) self.itemBoot = DirectFrame(parent=self.itemFrame, relief=None, image=bootGui, scale=0.2) self.itemPackage = DirectFrame(parent=self.itemFrame, relief=None, image=packageGui, scale=0.25) self.itemJellybean.hide() self.itemBoot.hide() self.itemPackage.hide() self.failureDialog = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('failureDialog'), doneEvent=self.uniqueName('failureDialog'), command=self.__userExit, message=TTLocalizer.FishingFailure, style=TTDialog.CancelOnly, cancelButtonText=TTLocalizer.FishingExit) self.failureDialog.hide() self.sellFishDialog = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('sellFishDialog'), doneEvent=self.uniqueName('sellFishDialog'), command=self.__sellFish, message=TTLocalizer.FishBingoOfferToSellFish, style=TTDialog.YesNo) self.sellFishDialog.hide() self.sellFishConfirmDialog = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('sellFishConfirmDialog'), doneEvent=self.uniqueName('sellFishConfirmDialog'), command=self.__sellFishConfirm, message=TTLocalizer.STOREOWNER_TROPHY, style=TTDialog.Acknowledge) self.sellFishConfirmDialog.hide() self.brokeDialog = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('brokeDialog'), doneEvent=self.uniqueName('brokeDialog'), command=self.__userExit, message=TTLocalizer.FishingBroke, style=TTDialog.CancelOnly, cancelButtonText=TTLocalizer.FishingExit) self.brokeDialog.hide() self.howToDialog = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('howToDialog'), doneEvent=self.uniqueName('howToDialog'), fadeScreen=0, message=TTLocalizer.FishingHowToFailed, style=TTDialog.Acknowledge) self.howToDialog['command'] = self.__hideHowTo self.howToDialog.setPos(-0.3, 0, 0.5) self.howToDialog.hide() self.madeGui = 1 return
def __handleExitShowWithConfirm(self): self.confirm = TTDialog.TTGlobalDialog(doneEvent='confirmDone', message=TTLocalizer.OptionsPageExitConfirm, style=TTDialog.TwoChoice) self.confirm.show() self._parent.doneStatus = {'mode': 'exit', 'exitTo': 'closeShard'} self.accept('confirmDone', self.__handleConfirm)
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 __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 makeTutorial(self): self.tutorial = TTDialog.TTDialog(fadeScreen=0, pad=(0.05, 0.05), midPad=0, topPad=0, sidePad=0, text=TTLocalizer.FishBingoHelpBlockout, style=TTDialog.NoButtons, pos=BG.TutorialPosition, scale=BG.TutorialScale) self.tutorial.hide()
def showThanks(self): self.confirm = TTDialog.TTGlobalDialog(doneEvent='confirmDone', message=SafezoneInvasionGlobals.Thanks, style=TTDialog.Acknowledge, suppressKeys=True) self.confirm.show() self.accept('confirmDone', self.handleConfirm)
def setMovie(self, mode, avId): """ This is a message from the AI describing a movie between this mailbox and a Toon that has approached us. """ # See if this is the local toon 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)) # This is an old movie in the server ram that has been cleared. # Just return and do nothing if (mode == MailboxGlobals.MAILBOX_MOVIE_CLEAR): DistributedMailbox.notify.debug("setMovie: clear") return elif (mode == MailboxGlobals.MAILBOX_MOVIE_EXIT): # Play one of the two mailbox closing sounds if random.random() < 0.5: sfx = base.loadSfx("phase_5.5/audio/sfx/mailbox_close_1.mp3") else: sfx = base.loadSfx("phase_5.5/audio/sfx/mailbox_close_2.mp3") 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") # Play one of the two mailbox opening sounds if random.random() < 0.5: sfx = base.loadSfx("phase_5.5/audio/sfx/mailbox_open_1.mp3") else: sfx = base.loadSfx("phase_5.5/audio/sfx/mailbox_open_2.mp3") sfxTrack = SoundInterval(sfx, node=self.model) sfxTrack.start() # If you are local toon, show the mailbox gui 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 __handleDelete(self, msg): self.confirmDelete = TTDialog.TTGlobalDialog(doneEvent='confirmDelete', message=TTLocalizer.MessageConfirmDelete % OTPLocalizer.CustomSCStrings[msg], style=TTDialog.TwoChoice) self.confirmDelete.msg = msg self.hide() self.confirmDelete.show() self.accept('confirmDelete', self.__handleDeleteConfirm)
def awardedTrophy(self, avId): if base.localAvatar.doId == avId: base.cr.playGame.getPlace().detectedGardenPlotUse() msg = TTLocalizer.GardenTrophyAwarded % (len(base.localAvatar.getFlowerCollection()), GardenGlobals.getNumberOfFlowerVarieties()) self.awardDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=msg, command=self.closedAwardDialog)
def chooseReportCategory(self): # put up a confirmation dialog - need to make a custom one for buttons self.dialog = TTDialog.TTGlobalDialog( pos = (0, 0, 0.2), style = TTDialog.CancelOnly, text = TTLocalizer.ReportPanelCategoryBody % (self.avName, self.avName), text_wordwrap = 18.5, text_scale = 0.06, topPad = 0.05, midPad = 0.65, cancelButtonText = TTLocalizer.lCancel, doneEvent = "ReportCategory", command = self.handleReportCategory, ) # Title DirectLabel( parent = self.dialog, relief = None, pos = (0, 0, 0.225), text = TTLocalizer.ReportPanelTitle, textMayChange = 0, text_scale = 0.08, ) guiButton = loader.loadModel("phase_3/models/gui/quit_button") # Foul Language DirectButton( parent = self.dialog, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale = (2.125, 1.0, 1.0), text = TTLocalizer.ReportPanelCategoryLanguage, text_scale = 0.06, text_pos = (0, -0.0124), pos = (0, 0, -0.3), command = self.handleReportCategory, extraArgs = [0], ) # Personal Info DirectButton( parent = self.dialog, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale = (2.25, 1.0, 1.0), text = TTLocalizer.ReportPanelCategoryPii, text_scale = 0.06, text_pos = (0, -0.0125), pos = (0, 0, -0.425), command = self.handleReportCategory, extraArgs = [1], ) # Rude Behavior DirectButton( parent = self.dialog, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale = (2.125, 1.0, 1.0), text = TTLocalizer.ReportPanelCategoryRude, text_scale = 0.06, text_pos = (0, -0.0125), pos = (0, 0, -0.55), command = self.handleReportCategory, extraArgs = [2], ) # Bad Name DirectButton( parent = self.dialog, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), image_scale = (2.125, 1.0, 1.0), text = TTLocalizer.ReportPanelCategoryName, text_scale = 0.06, text_pos = (0, -0.0125), pos = (0, 0, -0.675), command = self.handleReportCategory, extraArgs = [3], ) guiButton.removeNode() self.dialog.show() self.__acceptStoppedStateMsg() self.requestStopped()
def shardChoiceReject(self, shardId): self.confirm = TTDialog.TTGlobalDialog(doneEvent = 'confirmDone', message = TTLocalizer.ShardPageChoiceReject, style = TTDialog.Acknowledge) self.confirm.show() self.accept('confirmDone', self._ShardPage__handleConfirm)
def enterDisplayVotes(self, votes, directions, directionToGo, directionReason): if self.UseTrolleyResultsPanel: self.moveCameraToTrolley() self.hideMinigamesAndBonuses() else: self.moveCameraToTop() self.resultVotes = votes self.resultDirections = directions self.directionToGo = directionToGo self.directionReason = directionReason self.resultsStr = '' directionTotals = [0] * TravelGameGlobals.MaxDirections for index in xrange(len(votes)): if index < len(self.avNames): avId = self.avIdList[index] dir = directions[index] numVotes = votes[index] directionTotals[dir] += numVotes curStr = TTLocalizer.TravelGameOneToonVote % { 'name': self.avNames[index], 'numVotes': numVotes, 'dir': TTLocalizer.TravelGameDirections[dir] } if not (numVotes == 0 and avId in self.disconnectedAvIds): self.resultsStr += curStr directionStr = TTLocalizer.TravelGameTotals for index in xrange(len(directionTotals)): directionStr += ' ' + TTLocalizer.TravelGameDirections[index] + ':' directionStr += str(directionTotals[index]) directionStr += '\n' self.resultsStr += directionStr reasonStr = '' if directionReason == TravelGameGlobals.ReasonVote: if directionToGo == 0: losingDirection = 1 else: losingDirection = 0 diffVotes = directionTotals[directionToGo] - directionTotals[ losingDirection] reasonStr = '' if diffVotes > 1: reasonStr = TTLocalizer.TravelGameReasonVotesPlural % { 'dir': TTLocalizer.TravelGameDirections[directionToGo], 'numVotes': diffVotes } else: reasonStr = TTLocalizer.TravelGameReasonVotesSingular % { 'dir': TTLocalizer.TravelGameDirections[directionToGo], 'numVotes': diffVotes } elif directionReason == TravelGameGlobals.ReasonRandom: reasonStr = TTLocalizer.TravelGameReasonRandom % { 'dir': TTLocalizer.TravelGameDirections[directionToGo], 'numVotes': directionTotals[directionToGo] } elif directionReason == TravelGameGlobals.ReasonPlaceDecider: reasonStr = TravelGameReasonPlace % { 'name': 'TODO NAME', 'dir': TTLocalizer.TravelGameDirections[directionToGo] } self.resultsStr += reasonStr self.dialog = TTDialog.TTDialog(text=self.resultsStr, command=self.__cleanupDialog, style=TTDialog.NoButtons, pos=(0, 0, 1)) self.dialog.hide() if self.UseTrolleyResultsPanel: self.votesPanel = VoteResultsTrolleyPanel.VoteResultsTrolleyPanel( len(self.avIdList), self.avIdList, votes, directions, self.avNames, self.disconnectedAvIds, directionToGo, directionReason, directionTotals) else: self.votesPanel = VoteResultsPanel.VoteResultsPanel( len(self.avIdList), self.avIdList, votes, directions, self.avNames, self.disconnectedAvIds, directionToGo, directionReason, directionTotals) self.votesPanel.startMovie() numPlayers = len(self.avIdList) if TravelGameGlobals.SpoofFour: numPlayers = 4 delay = TravelGameGlobals.DisplayVotesTimePerPlayer * (numPlayers + 1) taskMgr.doMethodLater(delay, self.displayVotesTimeoutTask, self.taskName('displayVotes-timeout')) curSwitch = TravelGameGlobals.BoardLayouts[self.boardIndex][ self.currentSwitch] self.destSwitch = curSwitch['links'][directionToGo] self.updateCurrentVotes()
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 enterWinMovie(self): resultStr = TTLocalizer.TravelGamePlaying % { 'game': self.idToNames[self.switchToMinigameDict[self.currentSwitch]] } numToons = 0 for avId in self.avIdList: if avId not in self.disconnectedAvIds: numToons += 1 if numToons <= 1: resultStr = TTLocalizer.TravelGameGoingBackToShop reachedGoalStr = None localAvatarWon = False localAvatarLost = False noWinner = True for avId in self.avIdBonuses.keys(): name = '' avatar = self.getAvatar(avId) if avatar: name = avatar.getName() if self.avIdBonuses[avId][0] == self.currentSwitch: noWinner = False reachedGoalStr = TTLocalizer.TravelGameGotBonus % { 'name': name, 'numBeans': self.avIdBonuses[avId][1] } if avId == base.localAvatar.doId: if not TravelGameGlobals.ReverseWin: self.wonGameSfx.play() bonusLabel = self.switchToBonusLabelDict[ self.currentSwitch] self.flashWinningBeansTrack = Sequence( LerpColorScaleInterval(bonusLabel, 0.75, Vec4(0.5, 1, 0.5, 1)), LerpColorScaleInterval(bonusLabel, 0.75, Vec4(1, 1, 1, 1))) self.flashWinningBeansTrack.loop() else: self.lostGameSfx.play() elif not TravelGameGlobals.ReverseWin: self.lostGameSfx.play() else: self.wonGameSfx.play() if noWinner: self.noWinnerSfx.play() resultStr += '\n\n' resultStr += TTLocalizer.TravelGameNoOneGotBonus if reachedGoalStr: resultStr += '\n\n' resultStr += reachedGoalStr self.winDialog = TTDialog.TTDialog(text=resultStr, command=self.__cleanupWinDialog, style=TTDialog.NoButtons) info = TravelGameGlobals.BoardLayouts[self.boardIndex][ self.currentSwitch] leafX, leafY, leafZ = info['pos'] endX = leafX + TravelGameGlobals.xInc heading = 90 moveTrolley = Sequence() moveTrolley.append( LerpHprInterval(self.trolleyCar, 1, Vec3(heading, 0, 0))) moveTrolley.append( LerpPosInterval(self.trolleyCar, 3, Vec3(endX + 20, leafY, 0))) soundTrack = Sequence() trolleyExitBellInterval = SoundInterval(self.trolleyBellSfx, duration=1) trolleyExitAwayInterval = SoundInterval(self.trolleyAwaySfx, duration=3) soundTrack.append(trolleyExitBellInterval) soundTrack.append(trolleyExitAwayInterval) soundTrack.append(trolleyExitBellInterval) self.moveTrolleyIval = Parallel(moveTrolley, soundTrack) self.moveTrolleyIval.start() delay = 8 taskMgr.doMethodLater(delay, self.gameOverCallback, self.taskName('playMovie')) return
def setMovie(self, mode, avId, timestamp): """ This is a message from the AI describing a movie between this bank and a Toon that has approached us. """ self.notify.debug("setMovie(mode=%s, avId=%s, timestamp=%s)" % (mode, avId, timestamp)) timeStamp = globalClockDelta.localElapsedTime(timestamp) # See if this is the local toon 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): # This is an old movie in the server ram that has been cleared. # Just return and do nothing 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") # TODO: play animation on bank self.__putAwayToonJar(avId) elif (mode == BANK_MOVIE_WITHDRAW): self.notify.debug("setMovie: withdraw") # TODO: play animation on bank 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 __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 exitOSX(self): self.confirm = TTDialog.TTGlobalDialog(doneEvent='confirmDone', message=TTLocalizer.OptionsPageExitConfirm, style=TTDialog.TwoChoice) self.confirm.show() self.accept('confirmDone', self.handleConfirm)
def chooseReportCategory(self): self.dialog = TTDialog.TTGlobalDialog( pos=(0, 0, 0.4), style=TTDialog.CancelOnly, text=TTLocalizer.ReportPanelCategoryBody % (self.avName, self.avName), text_wordwrap=18.5, text_scale=0.06, topPad=0.05, midPad=0.75, cancelButtonText=TTLocalizer.lCancel, doneEvent='ReportCategory', command=self.handleReportCategory) DirectLabel(parent=self.dialog, relief=None, pos=(0, 0, 0.225), text=TTLocalizer.ReportPanelTitle, textMayChange=0, text_scale=0.08) guiButton = loader.loadModel('phase_3/models/gui/quit_button') DirectButton(parent=self.dialog, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(2.125, 1.0, 1.0), text=TTLocalizer.ReportPanelCategoryLanguage, text_scale=0.06, text_pos=(0, -0.0124), pos=(0, 0, -0.3), command=self.handleReportCategory, extraArgs=[0]) DirectButton(parent=self.dialog, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(2.15, 1.0, 1.0), text=TTLocalizer.ReportPanelCategoryPii, text_scale=0.06, text_pos=(0, -0.0125), pos=(0, 0, -0.425), command=self.handleReportCategory, extraArgs=[1]) DirectButton(parent=self.dialog, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(2.125, 1.0, 1.0), text=TTLocalizer.ReportPanelCategoryRude, text_scale=0.06, text_pos=(0, -0.0125), pos=(0, 0, -0.55), command=self.handleReportCategory, extraArgs=[2]) DirectButton(parent=self.dialog, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(2.125, 1.0, 1.0), text=TTLocalizer.ReportPanelCategoryName, text_scale=0.06, text_pos=(0, -0.0125), pos=(0, 0, -0.675), command=self.handleReportCategory, extraArgs=[3]) DirectButton(parent=self.dialog, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(2.125, 1.0, 1.0), text=TTLocalizer.ReportPanelCategoryHacking, text_scale=0.06, text_pos=(0, -0.0125), pos=(0, 0, -0.8), command=self.handleReportCategory, extraArgs=[4]) guiButton.removeNode() self.dialog.show() self.__acceptStoppedStateMsg() self.requestStopped() return
def rejectName(self, str): self.notify.debug('rejectName') self.names[0] = '' self.rejectDialog = TTDialog.TTGlobalDialog(doneEvent='rejectDone', message=str, style=TTDialog.Acknowledge) self.rejectDialog.show() self.acceptOnce('rejectDone', self.__handleReject)
def enterTeleportIn(self, requestStatus): imgScale = 0.25 if self.dialog: x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) elif base.localAvatar.hp < 1: requestStatus['nextState'] = 'popup' x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) self.accept('deathAck', self.__handleDeathAck, extraArgs=[requestStatus]) self.deathAckBox = DeathForceAcknowledge.DeathForceAcknowledge( doneEvent='deathAck') elif base.localAvatar.hp > 0 and ( Quests.avatarHasTrolleyQuest(base.localAvatar) or Quests.avatarHasFirstCogQuest(base.localAvatar) or Quests.avatarHasFriendQuest(base.localAvatar) or Quests.avatarHasPhoneQuest(base.localAvatar) and Quests.avatarHasCompletedPhoneQuest(base.localAvatar) ) and self.loader.hood.id == ToontownGlobals.ToontownCentral: requestStatus['nextState'] = 'popup' imageModel = loader.loadModel('phase_4/models/gui/tfa_images') if base.localAvatar.quests[0][0] == Quests.TROLLEY_QUEST_ID: if not Quests.avatarHasCompletedTrolleyQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralInitialDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage3 imgNodePath = imageModel.find('**/trolley-dialog-image') imgPos = (0, 0, 0.04) imgScale = 0.5 else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage4 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, -0.02) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.FIRST_COG_QUEST_ID: if not Quests.avatarHasCompletedFirstCogQuest( base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralTunnelDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage5 imgNodePath = imageModel.find('**/tunnelSignA') imgPos = (0, 0, 0.04) imgScale = 0.5 else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage6 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.FRIEND_QUEST_ID: if not Quests.avatarHasCompletedFriendQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralInitialDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage7 gui = loader.loadModel( 'phase_3.5/models/gui/friendslist_gui') imgNodePath = gui.find('**/FriendsBox_Closed') imgPos = (0, 0, 0.04) imgScale = 1.0 gui.removeNode() else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage8 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.PHONE_QUEST_ID: if Quests.avatarHasCompletedPhoneQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage9 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 self.dialog = TTDialog.TTDialog(text=msg, command=self.__cleanupDialog, style=TTDialog.Acknowledge) imgLabel = DirectLabel.DirectLabel(parent=self.dialog, relief=None, pos=imgPos, scale=TTLocalizer.PimgLabel, image=imgNodePath, image_scale=imgScale) imageModel.removeNode() else: requestStatus['nextState'] = 'walk' x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) base.localAvatar.detachNode() base.localAvatar.setPosHpr(render, x, y, z, h, p, r) Place.Place.enterTeleportIn(self, requestStatus) return
def waitForServer(self): self.waitForServerDialog = TTDialog.TTDialog(text=TTLocalizer.WaitingForNameSubmission, style=TTDialog.NoButtons) self.waitForServerDialog.show()
def __init__(self, doneEvent): StateData.StateData.__init__(self, doneEvent) self.numCogs = 1 self.creditLevel = None self.luredIndices = [] self.trappedIndices = [] self.numToons = 1 self.toons = [] self.localNum = 0 self.time = 0 self.bldg = 0 self.track = -1 self.level = -1 self.target = 0 self.toonAttacks = [(-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0)] self.fsm = ClassicFSM.ClassicFSM('TownBattle', [ State.State('Off', self.enterOff, self.exitOff, ['Attack']), State.State('Attack', self.enterAttack, self.exitAttack, ['ChooseCog', 'ChooseToon', 'AttackWait', 'Run', 'Fire', 'SOS']), State.State('ChooseCog', self.enterChooseCog, self.exitChooseCog, ['AttackWait', 'Attack']), State.State('AttackWait', self.enterAttackWait, self.exitAttackWait, ['ChooseCog', 'ChooseToon', 'Attack']), State.State('ChooseToon', self.enterChooseToon, self.exitChooseToon, ['AttackWait', 'Attack']), State.State('Run', self.enterRun, self.exitRun, ['Attack']), State.State('SOS', self.enterSOS, self.exitSOS, ['Attack', 'AttackWait', 'SOSPetSearch', 'SOSPetInfo']), State.State('SOSPetSearch', self.enterSOSPetSearch, self.exitSOSPetSearch, ['SOS', 'SOSPetInfo']), State.State('SOSPetInfo', self.enterSOSPetInfo, self.exitSOSPetInfo, ['SOS', 'AttackWait']), State.State('Fire', self.enterFire, self.exitFire, ['Attack', 'AttackWait'])], 'Off', 'Off') self.runPanel = TTDialog.TTDialog(dialogName='TownBattleRunPanel', text=TTLocalizer.TownBattleRun, style=TTDialog.TwoChoice, command=self.__handleRunPanelDone) self.runPanel.hide() self.attackPanelDoneEvent = 'attack-panel-done' self.attackPanel = TownBattleAttackPanel.TownBattleAttackPanel(self.attackPanelDoneEvent) self.waitPanelDoneEvent = 'wait-panel-done' self.waitPanel = TownBattleWaitPanel.TownBattleWaitPanel(self.waitPanelDoneEvent) self.chooseCogPanelDoneEvent = 'choose-cog-panel-done' self.chooseCogPanel = TownBattleChooseAvatarPanel.TownBattleChooseAvatarPanel(self.chooseCogPanelDoneEvent, 0) self.chooseToonPanelDoneEvent = 'choose-toon-panel-done' self.chooseToonPanel = TownBattleChooseAvatarPanel.TownBattleChooseAvatarPanel(self.chooseToonPanelDoneEvent, 1) self.SOSPanelDoneEvent = 'SOS-panel-done' self.SOSPanel = TownBattleSOSPanel.TownBattleSOSPanel(self.SOSPanelDoneEvent) self.SOSPetSearchPanelDoneEvent = 'SOSPetSearch-panel-done' self.SOSPetSearchPanel = TownBattleSOSPetSearchPanel.TownBattleSOSPetSearchPanel(self.SOSPetSearchPanelDoneEvent) self.SOSPetInfoPanelDoneEvent = 'SOSPetInfo-panel-done' self.SOSPetInfoPanel = TownBattleSOSPetInfoPanel.TownBattleSOSPetInfoPanel(self.SOSPetInfoPanelDoneEvent) self.fireCogPanelDoneEvent = 'fire-cog-panel-done' self.FireCogPanel = FireCogPanel.FireCogPanel(self.fireCogPanelDoneEvent) self.cogFireCosts = [None, None, None, None] self.toonPanels = (TownBattleToonPanel.TownBattleToonPanel(0), TownBattleToonPanel.TownBattleToonPanel(1), TownBattleToonPanel.TownBattleToonPanel(2), TownBattleToonPanel.TownBattleToonPanel(3)) self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(base.a2dTopRight) self.timer.setPos(-0.151, 0, -0.158) self.timer.setScale(0.4) self.timer.hide() return
def handleStopIgnoring(self): self.dialog = TTDialog.TTGlobalDialog(style = TTDialog.TwoChoice, text = TTLocalizer.IgnorePanelRemoveIgnore % self.avName, text_wordwrap = 18.5, text_scale = 0.059999999999999998, okButtonText = TTLocalizer.AvatarPanelStopIgnoring, cancelButtonText = TTLocalizer.lCancel, buttonPadSF = 4.0, doneEvent = 'StopIgnoringConfirm', command = self.handleStopIgnoringConfirm) DirectLabel(parent = self.dialog, relief = None, pos = (0, TTLocalizer.APBdirectLabelPosY, 0.14999999999999999), text = TTLocalizer.IgnorePanelTitle, textMayChange = 0, text_scale = 0.080000000000000002) self.dialog.show() self._AvatarPanelBase__acceptStoppedStateMsg() self.requestStopped()
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)