From 7053ae86764511db90d1e964722e6bbfab57db22 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 17 Aug 2015 16:21:07 +0300 Subject: [PATCH] Add teleport toggle and prevent teleportation when ignored --- toontown/friends/TTSFriendsManager.py | 6 ++++++ toontown/shtiker/OptionsPage.py | 28 +++++++++++++++++++++++-- toontown/toon/LocalToon.py | 6 ++++++ toontown/toon/ToonTeleportPanel.py | 14 ++++++++++++- toontown/toonbase/TTLocalizerEnglish.py | 4 ++++ 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/toontown/friends/TTSFriendsManager.py b/toontown/friends/TTSFriendsManager.py index 10e8a519..5349865f 100755 --- a/toontown/friends/TTSFriendsManager.py +++ b/toontown/friends/TTSFriendsManager.py @@ -72,6 +72,12 @@ class TTSFriendsManager(DistributedObjectGlobal): if not hasattr(base.localAvatar, 'getTeleportAvailable') or not hasattr(base.localAvatar, 'ghostMode'): self.sendUpdate('teleportResponse', [ fromId, 0, 0, 0, 0 ]) return + if not base.localAvatar.acceptingTeleport: + self.sendUpdate('teleportResponse', [ fromId, 3, 0, 0, 0 ]) + return + if base.localAvatar.isIgnored(fromId): + self.sendUpdate('teleportResponse', [ fromId, 2, 0, 0, 0 ]) + return friend = base.cr.identifyFriend(fromId) diff --git a/toontown/shtiker/OptionsPage.py b/toontown/shtiker/OptionsPage.py index c7f92c29..afa5cdeb 100755 --- a/toontown/shtiker/OptionsPage.py +++ b/toontown/shtiker/OptionsPage.py @@ -731,25 +731,28 @@ class ExtraOptionsTabPage(DirectFrame): self.fov_label = DirectLabel(parent=self, relief=None, text=TTLocalizer.FieldOfViewLabel, text_align=TextNode.ALeft, text_scale=options_text_scale, text_wordwrap=16, pos=(leftMargin, 0, textStartHeight)) self.cogInterface_label = DirectLabel(parent=self, relief=None, text='', text_align=TextNode.ALeft, text_scale=options_text_scale, text_wordwrap=16, pos=(leftMargin, 0, textStartHeight - textRowHeight)) self.tpTransition_label = DirectLabel(parent=self, relief=None, text='', text_align=TextNode.ALeft, text_scale=options_text_scale, text_wordwrap=16, pos=(leftMargin, 0, textStartHeight - 2 * textRowHeight)) + self.teleport_label = DirectLabel(parent=self, relief=None, text='', text_align=TextNode.ALeft, text_scale=options_text_scale, text_wordwrap=16, pos=(leftMargin, 0, textStartHeight - 3 * textRowHeight)) self.fov_slider = DirectSlider(parent=self, pos=(buttonbase_xcoord, 0.0, buttonbase_ycoord), value=settings['fov'], pageSize=5, range=(ToontownGlobals.DefaultCameraFov, ToontownGlobals.MaxCameraFov), command=self.__doFov, thumb_geom=(circleModel.find('**/tt_t_gui_mat_namePanelCircle')), thumb_relief=None, thumb_geom_scale=2) self.fov_slider.setScale(0.25) self.cogInterface_toggleButton = DirectButton(parent=self, relief=None, image=button_image, image_scale=button_image_scale, text='', text_scale=options_text_scale, text_pos=button_textpos, pos=(buttonbase_xcoord, 0.0, buttonbase_ycoord - textRowHeight), command=self.__doToggleCogInterface) self.tpTransition_toggleButton = DirectButton(parent=self, relief=None, image=button_image, image_scale=button_image_scale, text='', text_scale=options_text_scale, text_pos=button_textpos, pos=(buttonbase_xcoord, 0.0, buttonbase_ycoord - 2 * textRowHeight), command=self.__doToggleTpTransition) + self.teleport_toggleButton = DirectButton(parent=self, relief=None, image=button_image, image_scale=button_image_scale, text='', text_scale=options_text_scale, text_pos=button_textpos, pos=(buttonbase_xcoord, 0.0, buttonbase_ycoord - 3 * textRowHeight), command=self.__doToggleTeleport) self.bugReportButton = DirectButton(parent=self, relief=None, text=TTLocalizer.BugReportButton, image=button_image, image_scale=button_image_scale, text_pos=(0, -0.01), text_fg=(0, 0, 0, 1), command=self.showReportNotice, pos=(0.0, 0.0, -0.6), text_scale=(0.045)) guiButton.removeNode() circleModel.removeNode() - self.optionChoosers['pole'] = OptionChooser.OptionChooser(self, TTLocalizer.FishingPoleLabel, 3, self.__updateFishingPole, [False], self.__applyFishingPole) - self.optionChoosers['nametag_style'] = OptionChooser.OptionChooser(self, TTLocalizer.NametagStyleLabel, 4, self.__updateNametagStyle, [False], self.__applyNametagStyle) + self.optionChoosers['pole'] = OptionChooser.OptionChooser(self, TTLocalizer.FishingPoleLabel, 4, self.__updateFishingPole, [False], self.__applyFishingPole) + self.optionChoosers['nametag_style'] = OptionChooser.OptionChooser(self, TTLocalizer.NametagStyleLabel, 5, self.__updateNametagStyle, [False], self.__applyNametagStyle) def enter(self): self.show() self.settingsChanged = 0 self.__setCogInterfaceButton() self.__setTpTransitionButton() + self.__setTeleportButton() self.__updateNametagStyle() self.__updateFishingPole() self.accept('refreshNametagStyle', self.__updateNametagStyle) @@ -776,6 +779,10 @@ class ExtraOptionsTabPage(DirectFrame): del self.tpTransition_label self.tpTransition_toggleButton.destroy() del self.tpTransition_toggleButton + self.teleport_label.destroy() + del self.teleport_label + self.teleport_toggleButton.destroy() + del self.teleport_toggleButton self.bugReportButton.destroy() del self.bugReportButton self.destroyReportNotice() @@ -807,6 +814,23 @@ class ExtraOptionsTabPage(DirectFrame): def __setTpTransitionButton(self): self.tpTransition_label['text'] = TTLocalizer.TpTransitionLabelOn if settings['tpTransition'] else TTLocalizer.TpTransitionLabelOff self.tpTransition_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff if settings['tpTransition'] else TTLocalizer.OptionsPageToggleOn + + def __doToggleTeleport(self): + messenger.send('wakeup') + acceptingTeleport = settings.get('acceptingTeleport', {}) + if base.localAvatar.acceptingTeleport: + base.localAvatar.acceptingTeleport = 0 + acceptingTeleport[str(base.localAvatar.doId)] = False + else: + base.localAvatar.acceptingTeleport = 1 + acceptingTeleport[str(base.localAvatar.doId)] = True + settings['acceptingTeleport'] = acceptingTeleport + self.settingsChanged = 1 + self.__setTeleportButton() + + def __setTeleportButton(self): + self.teleport_label['text'] = TTLocalizer.TeleportLabelOn if base.localAvatar.acceptingTeleport else TTLocalizer.TeleportLabelOff + self.teleport_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff if base.localAvatar.acceptingTeleport else TTLocalizer.OptionsPageToggleOn def __updateNametagStyle(self, resetIndex=True): chooser = self.optionChoosers['nametag_style'] diff --git a/toontown/toon/LocalToon.py b/toontown/toon/LocalToon.py index 6a54f2fe..5d8e211d 100755 --- a/toontown/toon/LocalToon.py +++ b/toontown/toon/LocalToon.py @@ -150,6 +150,7 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.createSystemMsgAckGui() self.acceptingNewFriends = True self.acceptingNonFriendWhispers = True + self.acceptingTeleport = True self.physControls.event.addAgainPattern('again%in') self.oldPos = None self.questMap = None @@ -214,14 +215,19 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): acceptingNewFriends = settings.get('acceptingNewFriends', {}) acceptingNonFriendWhispers = settings.get('acceptingNonFriendWhispers', {}) + acceptingTeleport = settings.get('acceptingTeleport', {}) if str(self.doId) not in acceptingNewFriends: acceptingNewFriends[str(self.doId)] = True settings['acceptingNewFriends'] = acceptingNewFriends if str(self.doId) not in acceptingNonFriendWhispers: acceptingNonFriendWhispers[str(self.doId)] = True settings['acceptingNonFriendWhispers'] = acceptingNonFriendWhispers + if str(self.doId) not in acceptingTeleport: + acceptingTeleport[str(self.doId)] = True + settings['acceptingTeleport'] = acceptingTeleport self.acceptingNewFriends = acceptingNewFriends[str(self.doId)] self.acceptingNonFriendWhispers = acceptingNonFriendWhispers[str(self.doId)] + self.acceptingTeleport = acceptingTeleport[str(self.doId)] def disable(self): self.laffMeter.destroy() diff --git a/toontown/toon/ToonTeleportPanel.py b/toontown/toon/ToonTeleportPanel.py index b26a676d..43005fc4 100755 --- a/toontown/toon/ToonTeleportPanel.py +++ b/toontown/toon/ToonTeleportPanel.py @@ -62,6 +62,9 @@ class ToonTeleportPanel(DirectFrame): State.State('ignored', self.enterIgnored, self.exitIgnored), + State.State('noTeleport', + self.enterNoTeleport, + self.exitNoTeleport), State.State('notOnline', self.enterNotOnline, self.exitNotOnline), @@ -148,11 +151,18 @@ class ToonTeleportPanel(DirectFrame): self.bOk.hide() def enterIgnored(self): - self['text'] = TTLocalizer.TeleportPanelNotAvailable % self.avName + self['text'] = TTLocalizer.TeleportPanelIgnored % self.avName self.bOk.show() def exitIgnored(self): self.bOk.hide() + + def enterNoTeleport(self): + self['text'] = TTLocalizer.TeleportPanelNoTeleport % self.avName + self.bOk.show() + + def exitNoTeleport(self): + self.bOk.hide() def enterNotOnline(self): self['text'] = TTLocalizer.TeleportPanelNotOnline % self.avName @@ -270,6 +280,8 @@ class ToonTeleportPanel(DirectFrame): elif available == 2: teleportNotify.debug('__teleportResponse: ignored') self.fsm.request('ignored') + elif available == 3: + self.fsm.request('noTeleport') elif shardId != base.localAvatar.defaultShard: teleportNotify.debug('__teleportResponse: otherShard') self.fsm.request('otherShard', [shardId, hoodId, zoneId]) diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 7af08d9e..303ca50b 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8743,6 +8743,10 @@ BattleSOSPopupHP = '%s %s HP\n' DetailPanelSOS = 'SOS Cards' +TeleportLabelOn = 'Accepting teleports.' +TeleportLabelOff = 'Not accepting teleports.' +TeleportPanelNoTeleport = '%s needs some time alone right now.' + Blacklist = [ "$1ut", "$h1t",