From 0c56b7c78d796ad21b19990a718586f40101a350 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 31 May 2015 16:50:03 +0300 Subject: [PATCH] DANIEL: True friends --- toontown/toon/AvatarPanelBase.py | 5 ++- toontown/toon/DistributedToon.py | 11 +++++++ toontown/toon/ToonAvatarPanel.py | 42 ++++++++++++++++++++++--- toontown/toonbase/TTLocalizerEnglish.py | 5 +++ 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/toontown/toon/AvatarPanelBase.py b/toontown/toon/AvatarPanelBase.py index 3dda3b5c..fc11d355 100755 --- a/toontown/toon/AvatarPanelBase.py +++ b/toontown/toon/AvatarPanelBase.py @@ -192,13 +192,12 @@ class AvatarPanelBase(AvatarPanel.AvatarPanel): self.cleanupDialog() self.requestWalk() - def cleanupDialog(self): + def cleanupDialog(self, state=None): if self.dialog: base.cr.openAvatarPanels.discard(self) self.dialog.ignore('exitingStoppedState') self.dialog.cleanup() self.dialog = None - return def requestStopped(self): base.cr.openAvatarPanels.add(self) @@ -221,4 +220,4 @@ class AvatarPanelBase(AvatarPanel.AvatarPanel): def __acceptStoppedStateMsg(self): self.dialog.ignore('exitingStoppedState') - self.dialog.accept('exitingStoppedState', self.cleanupDialog) + self.dialog.accept('exitingStoppedState', self.cleanupDialog) \ No newline at end of file diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 7885d0a8..56c75910 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -2526,6 +2526,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute self.d_setTrueFriends(trueFriends) def setTrueFriends(self, trueFriends): + Avatar.reconsiderAllUnderstandable() self.trueFriends = trueFriends def d_setTrueFriends(self, trueFriends): @@ -2533,6 +2534,16 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def isTrueFriends(self, doId): return doId in self.trueFriends + + def addTrueFriends(self, doId): + if not self.isTrueFriends(doId): + self.trueFriends.append(doId) + self.b_setTrueFriends(self.trueFriends) + + def removeTrueFriends(self, doId): + if self.isTrueFriends(doId): + self.trueFriends.remove(doId) + self.b_setTrueFriends(self.trueFriends) def applyBuffs(self): for id, timestamp in enumerate(self.buffs): diff --git a/toontown/toon/ToonAvatarPanel.py b/toontown/toon/ToonAvatarPanel.py index 3899deac..9945d47a 100755 --- a/toontown/toon/ToonAvatarPanel.py +++ b/toontown/toon/ToonAvatarPanel.py @@ -364,10 +364,6 @@ class ToonAvatarPanel(AvatarPanelBase.AvatarPanelBase): def __handleWhisper(self): base.localAvatar.chatMgr.whisperTo(self.avName, self.avId) - def __handleTrueFriends(self): - base.localAvatar.chatMgr.noWhisper() - # TODO - def __handleFriend(self): base.localAvatar.chatMgr.noWhisper() messenger.send('friendAvatar', [self.avId, self.avName, self.avDisableName]) @@ -552,3 +548,41 @@ class ToonAvatarPanel(AvatarPanelBase.AvatarPanelBase): groupAvatarBgGui.removeNode() helpGui.removeNode() return + + def __handleTrueFriends(self): + 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 confirmTrueFriendsAdd(self, state): + self.cleanupDialog() + + if state > 0: + base.localAvatar.addTrueFriends(self.avatar.doId) + self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.TrueFriendsAdded.replace('%s', self.avatar.getName()), text_wordwrap=20, command=self.cleanupDialogAndWalk) + self.dialog.show() + else: + base.cr.playGame.getPlace().fsm.request('walk') + + def confirmTrueFriendsRemove(self, state): + self.cleanupDialog() + + if state > 0: + base.localAvatar.removeTrueFriends(self.avatar.doId) + self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.TrueFriendsRemoved % self.avatar.getName(), text_wordwrap=20, command=self.cleanupDialogAndWalk) + self.dialog.show() + else: + base.cr.playGame.getPlace().fsm.request('walk') + + def cleanupDialogAndWalk(self, state=None): + self.cleanupDialog() + base.cr.playGame.getPlace().fsm.request('walk') \ No newline at end of file diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 6d84211c..96d7aea0 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8461,3 +8461,8 @@ CogPanelSkeleton = 'Skeleton' CogPanelVirtual = 'Virtual' CogPanelRevives = 'v%s.0' CogPanelWaiter = 'Waiter' +TrueFriendsRemoveNotice = 'Are you sure you want to remove %s as your True Friend?\n\nYou will no longer be able to chat without limits.' +TrueFriendsNotFriends = 'You cannot be True Friends with %s until you are regular friends first.' +TrueFriendsAddNotice = 'If you are playing Toontown with someone you trust, you can become True Friends.\n\nYou can chat using the keyboard with your True Friends.\n\nOther Toons won\'t understand what you\'re saying.\n\n\x01WLRed\x01However, this chat is completely unfiltered.\x02\n\nAre you sure you want to be True Friends with %s?' +TrueFriendsAdded = 'You are now True Friends with %s!\n\nYou can now understand everything %s says.\n\nHowever, chances are %s hasn\'t added you as a True Friend yet.\n\nIf this is the case, he cannot understand you yet. Please ask %s to add you as a True Friend aswell!' +TrueFriendsRemoved = 'You are no longer True Friends with %s.'