{"action":"created","issue":{"url":"https://api.github.com/repos/ToontownInfinite/src/issues/323","labels_url":"https://api.github.com/repos/ToontownInfinite/src/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/ToontownInfinite/src/issues/323/comments","events_url":"https://api.github.com/repos/ToontownInfinite/src/issues/323/events","html_url":"https://github.com/ToontownInfinite/src/pull/323","id":58408553,"number":323,"title":"ToonTeleportPanel.py","user":{"login":"alexbutlerisawesome","id":11096497,"avatar_url":"https://avatars.githubusercontent.com/u/11096497?v=3","gravatar_id":"","url":"https://api.github.com/users/alexbutlerisawesome","html_url":"https://github.com/alexbutlerisawesome","followers_url":"https://api.github.com/users/alexbutlerisawesome/followers","following_url":"https://api.github.com/users/alexbutlerisawesome/following{/other_user}","gists_url":"https://api.github.com/users/alexbutlerisawesome/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbutlerisawesome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbutlerisawesome/subscriptions","organizations_url":"https://api.github.com/users/alexbutlerisawesome/orgs","repos_url":"https://api.github.com/users/alexbutlerisawesome/repos","events_url":"https://api.github.com/users/alexbutlerisawesome/events{/privacy}","received_events_url":"https://api.github.com/users/alexbutlerisawesome/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-20T20:50:15Z","updated_at":"2015-02-20T21:29:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ToontownInfinite/src/pulls/323","html_url":"https://github.com/ToontownInfinite/src/pull/323","diff_url":"https://github.com/ToontownInfinite/src/pull/323.diff","patch_url":"https://github.com/ToontownInfinite/src/pull/323.patch"},"body":"\r\nfrom pandac.PandaModules import *\r\nfrom direct.gui.DirectGui import *\r\nfrom pandac.PandaModules import *\r\nfrom toontown.toonbase import ToontownGlobals\r\nfrom direct.showbase import DirectObject\r\nfrom direct.fsm import ClassicFSM, State\r\nfrom direct.fsm import State\r\nfrom direct.directnotify import DirectNotifyGlobal\r\nfrom otp.avatar.Avatar import teleportNotify\r\nimport ToonAvatarDetailPanel\r\nfrom toontown.toonbase import TTLocalizer\r\nfrom toontown.hood import ZoneUtil\r\nglobalTeleport = None\r\n\r\ndef showTeleportPanel(avId, avName, avDisableName):\r\n    global globalTeleport\r\n    if globalTeleport != None:\r\n        globalTeleport.cleanup()\r\n        globalTeleport = None\r\n    globalTeleport = ToonTeleportPanel(avId, avName, avDisableName)\r\n    return\r\n\r\n\r\ndef hideTeleportPanel():\r\n    global globalTeleport\r\n    if globalTeleport != None:\r\n        globalTeleport.cleanup()\r\n        globalTeleport = None\r\n    return\r\n\r\n\r\ndef unloadTeleportPanel():\r\n    global globalTeleport\r\n    if globalTeleport != None:\r\n        globalTeleport.cleanup()\r\n        globalTeleport = None\r\n    return\r\n\r\n\r\nclass ToonTeleportPanel(DirectFrame):\r\n    notify = DirectNotifyGlobal.directNotify.newCategory('ToonTeleportPanel')\r\n\r\n    def __init__(self, avId, avName, avDisableName):\r\n        DirectFrame.__init__(self, pos=(-1.01, 0.1, -0.35), parent=base.a2dTopRight, image_color=ToontownGlobals.GlobalDialogColor, image_scale=(1.0, 1.0, 0.6), text='', text_wordwrap=13.5, text_scale=0.06, text_pos=(0.0, 0.18))\r\n        messenger.send('releaseDirector')\r\n        self['image'] = DGG.getDefaultDialogGeom()\r\n        self.avId = avId\r\n        self.avName = avName\r\n        self.avDisableName = avDisableName\r\n        self.fsm = ClassicFSM.ClassicFSM('ToonTeleportPanel', [\r\n            State.State('off',\r\n                self.enterOff,\r\n                self.exitOff),\r\n            State.State('begin',\r\n                self.enterBegin,\r\n                self.exitBegin),\r\n            State.State('checkAvailability',\r\n                self.enterCheckAvailability,\r\n                self.exitCheckAvailability),\r\n            State.State('notAvailable',\r\n                self.enterNotAvailable,\r\n                self.exitNotAvailable),\r\n            State.State('ignored',\r\n                self.enterIgnored,\r\n                self.exitIgnored),\r\n            State.State('notOnline',\r\n                self.enterNotOnline,\r\n                self.exitNotOnline),\r\n            State.State('wentAway',\r\n                self.enterWentAway,\r\n                self.exitWentAway),\r\n            State.State('self',\r\n                self.enterSelf,\r\n                self.exitSelf),\r\n            State.State('unknownHood',\r\n                self.enterUnknownHood,\r\n                self.exitUnknownHood),\r\n            State.State('unavailableHood',\r\n                self.enterUnavailableHood,\r\n                self.exitUnavailableHood),\r\n            State.State('otherShard',\r\n                self.enterOtherShard,\r\n                self.exitOtherShard),\r\n            State.State('teleport',\r\n                self.enterTeleport,\r\n                self.exitTeleport)],\r\n            'off', 'off')\r\n        from toontown.friends import FriendInviter\r\n        FriendInviter.hideFriendInviter()\r\n        ToonAvatarDetailPanel.hideAvatarDetail()\r\n        buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')\r\n        self.bOk = DirectButton(self, image=(buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief=None, text=TTLocalizer.TeleportPanelOK, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.0, 0.0, -0.1), command=self.__handleOk)\r\n        self.bOk.hide()\r\n        self.bCancel = DirectButton(self, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), relief=None, text=TTLocalizer.TeleportPanelCancel, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.0, 0.0, -0.1), command=self.__handleCancel)\r\n        self.bCancel.hide()\r\n        self.bYes = DirectButton(self, image=(buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')), relief=None, text=TTLocalizer.TeleportPanelYes, text_scale=0.05, text_pos=(0.0, -0.1), pos=(-0.15, 0.0, -0.15), command=self.__handleYes)\r\n        self.bYes.hide()\r\n        self.bNo = DirectButton(self, image=(buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')), relief=None, text=TTLocalizer.TeleportPanelNo, text_scale=0.05, text_pos=(0.0, -0.1), pos=(0.15, 0.0, -0.15), command=self.__handleNo)\r\n        self.bNo.hide()\r\n        buttons.removeNode()\r\n        self.accept(self.avDisableName, self.__handleDisableAvatar)\r\n        self.show()\r\n        self.fsm.enterInitialState()\r\n        self.fsm.request('begin')\r\n        return\r\n\r\n    def cleanup(self):\r\n        self.fsm.request('off')\r\n        del self.fsm\r\n        self.ignore(self.avDisableName)\r\n        self.destroy()\r\n\r\n    def enterOff(self):\r\n        pass\r\n\r\n    def exitOff(self):\r\n        pass\r\n\r\n    def enterBegin(self):\r\n        myId = base.localAvatar.doId\r\n        hasManager = hasattr(base.cr, 'playerFriendsManager')\r\n        if self.avId == myId:\r\n            self.fsm.request('self')\r\n        elif self.avId in base.cr.doId2do:\r\n            self.fsm.request('checkAvailability')\r\n        elif base.cr.isFriend(self.avId):\r\n            if base.cr.isFriendOnline(self.avId):\r\n                self.fsm.request('checkAvailability')\r\n            else:\r\n                self.fsm.request('notOnline')\r\n        elif hasManager and base.cr.playerFriendsManager.getAvHandleFromId(self.avId):\r\n            id = base.cr.playerFriendsManager.findPlayerIdFromAvId(self.avId)\r\n            info = base.cr.playerFriendsManager.getFriendInfo(id)\r\n            if info:\r\n                if info.onlineYesNo:\r\n                    self.fsm.request('checkAvailability')\r\n                else:\r\n                    self.fsm.request('notOnline')\r\n            else:\r\n                self.fsm.request('wentAway')\r\n    def exitBegin(self):\r\n        pass\r\n\t\t\r\n    def enterCheckAvailability(self):\r\n        myId = base.localAvatar.getDoId()\r\n        base.cr.ttiFriendsManager.d_teleportQuery(self.avId)\r\n        self['text'] = TTLocalizer.TeleportPanelCheckAvailability % self.avName\r\n        self.accept('teleportResponse', self.__teleportResponse)\r\n        self.bCancel.show()\r\n\r\n    def exitCheckAvailability(self):\r\n        self.ignore('teleportResponse')\r\n        self.bCancel.hide()\r\n\r\n    def enterNotAvailable(self):\r\n        self['text'] = TTLocalizer.TeleportPanelNotAvailable % self.avName\r\n        self.bOk.show()\r\n\r\n    def exitNotAvailable(self):\r\n        self.bOk.hide()\r\n\r\n    def enterIgnored(self):\r\n        self['text'] = TTLocalizer.TeleportPanelNotAvailable % self.avName\r\n        self.bOk.show()\r\n\r\n    def exitIgnored(self):\r\n        self.bOk.hide()\r\n\r\n    def enterNotOnline(self):\r\n        self['text'] = TTLocalizer.TeleportPanelNotOnline % self.avName\r\n        self.bOk.show()\r\n\r\n    def exitNotOnline(self):\r\n        self.bOk.hide()\r\n\r\n    def enterWentAway(self):\r\n        self['text'] = TTLocalizer.TeleportPanelWentAway % self.avName\r\n        self.bOk.show()\r\n\r\n    def exitWentAway(self):\r\n        self.bOk.hide()\r\n\r\n    def enterUnknownHood(self, hoodId):\r\n        self['text'] = TTLocalizer.TeleportPanelUnknownHood % base.cr.hoodMgr.getFullnameFromId(hoodId)\r\n        self.bOk.show()\r\n\r\n    def exitUnknownHood(self):\r\n        self.bOk.hide()\r\n\r\n    def enterUnavailableHood(self, hoodId):\r\n        self['text'] = TTLocalizer.TeleportPanelUnavailableHood % base.cr.hoodMgr.getFullnameFromId(hoodId)\r\n        self.bOk.show()\r\n\r\n    def exitUnavailableHood(self):\r\n        self.bOk.hide()\r\n\r\n    def enterSelf(self):\r\n        self['text'] = TTLocalizer.TeleportPanelDenySelf\r\n        self.bOk.show()\r\n\r\n    def exitSelf(self):\r\n        self.bOk.hide()\r\n\r\n    def enterOtherShard(self, shardId, hoodId, zoneId):\r\n        shardName = base.cr.getShardName(shardId)\r\n        if shardName is None:\r\n            self.fsm.request('notAvailable')\r\n            return\r\n        myShardName = base.cr.getShardName(base.localAvatar.defaultShard)\r\n        pop = None\r\n        for shard in base.cr.listActiveShards():\r\n            if shard[0] == shardId:\r\n                pop = shard[2]\r\n\r\n        self.bYes.show()\r\n        self.bNo.show()\r\n\r\n        if pop and pop > localAvatar.shardPage.midPop:\r\n            self.notify.warning('Entering full shard: issuing performance warning')\r\n            self['text'] = TTLocalizer.TeleportPanelBusyShard % {'avName': self.avName}\r\n            self.bYes.hide()\r\n            self.bNo.hide()\r\n\r\n            self.bOk.show()\r\n        else:\r\n            self['text'] = TTLocalizer.TeleportPanelOtherShard % {'avName': self.avName,\r\n             'shardName': shardName,\r\n             'myShardName': myShardName}\r\n\r\n        self.shardId = shardId\r\n        self.hoodId = hoodId\r\n        self.zoneId = zoneId\r\n        return\r\n\r\n    def exitOtherShard(self):\r\n        self.bYes.hide()\r\n        self.bNo.hide()\r\n\r\n    def enterTeleport(self, shardId, hoodId, zoneId):\r\n        shardName = base.cr.getShardName(shardId)\r\n        if shardName is None:\r\n            shardName = 'unknown'\r\n        print 'enterTeleport: %r, %r, %r, %r, %r' % (shardId, shardName, hoodId, zoneId, self.avId)\r\n        hoodsVisited = base.localAvatar.hoodsVisited\r\n        canonicalHoodId = ZoneUtil.getCanonicalZoneId(hoodId)\r\n        if hoodId == ToontownGlobals.MyEstate:\r\n            teleportNotify.debug('enterTeleport: estate')\r\n            if shardId == base.localAvatar.defaultShard:\r\n                shardId = None\r\n            place = base.cr.playGame.getPlace()\r\n            place.requestTeleport(hoodId, zoneId, shardId, self.avId)\r\n            unloadTeleportPanel()\r\n        elif canonicalHoodId not in hoodsVisited + ToontownGlobals.HoodsAlwaysVisited:\r\n            teleportNotify.debug('enterTeleport: unknownHood')\r\n            self.fsm.request('unknownHood', [hoodId])\r\n        elif canonicalHoodId not in base.cr.hoodMgr.getAvailableZones():\r\n            print 'hoodId %d not ready' % hoodId\r\n            self.fsm.request('unavailableHood', [hoodId])\r\n        else:\r\n            if shardId == base.localAvatar.defaultShard:\r\n                shardId = None\r\n            teleportNotify.debug('enterTeleport: requesting teleport')\r\n            place = base.cr.playGame.getPlace()\r\n            place.requestTeleport(hoodId, zoneId, shardId, self.avId)\r\n            unloadTeleportPanel()\r\n        return\r\n\r\n    def exitTeleport(self):\r\n        pass\r\n\r\n    def __handleOk(self):\r\n        unloadTeleportPanel()\r\n\r\n    def __handleCancel(self):\r\n        unloadTeleportPanel()\r\n\r\n    def __handleYes(self):\r\n        self.fsm.request('teleport', [self.shardId, self.hoodId, self.zoneId])\r\n\r\n    def __handleNo(self):\r\n        unloadTeleportPanel()\r\n\r\n    def __teleportResponse(self, avId, available, shardId, hoodId, zoneId):\r\n        teleportNotify.debug('__teleportResponse%s' % ((avId,\r\n          available,\r\n          shardId,\r\n          hoodId,\r\n          zoneId),))\r\n        if avId != self.avId:\r\n            return\r\n        if available == 0:\r\n            teleportNotify.debug('__teleportResponse: not available')\r\n            self.fsm.request('notAvailable')\r\n        elif available == 2:\r\n            teleportNotify.debug('__teleportResponse: ignored')\r\n            self.fsm.request('ignored')\r\n        elif shardId != base.localAvatar.defaultShard:\r\n            teleportNotify.debug('__teleportResponse: otherShard')\r\n            self.fsm.request('otherShard', [shardId, hoodId, zoneId])\r\n        else:\r\n            teleportNotify.debug('__teleportResponse: teleport')\r\n            self.fsm.request('teleport', [shardId, hoodId, zoneId])\r\n\r\n    def __handleDisableAvatar(self):\r\n        self.fsm.request('wentAway')\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ToontownInfinite/src/issues/comments/75322385","html_url":"https://github.com/ToontownInfinite/src/pull/323#issuecomment-75322385","issue_url":"https://api.github.com/repos/ToontownInfinite/src/issues/323","id":75322385,"user":{"login":"mgracer48","id":10155689,"avatar_url":"https://avatars.githubusercontent.com/u/10155689?v=3","gravatar_id":"","url":"https://api.github.com/users/mgracer48","html_url":"https://github.com/mgracer48","followers_url":"https://api.github.com/users/mgracer48/followers","following_url":"https://api.github.com/users/mgracer48/following{/other_user}","gists_url":"https://api.github.com/users/mgracer48/gists{/gist_id}","starred_url":"https://api.github.com/users/mgracer48/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgracer48/subscriptions","organizations_url":"https://api.github.com/users/mgracer48/orgs","repos_url":"https://api.github.com/users/mgracer48/repos","events_url":"https://api.github.com/users/mgracer48/events{/privacy}","received_events_url":"https://api.github.com/users/mgracer48/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T21:29:00Z","updated_at":"2015-02-20T21:29:00Z","body":"closes do you mean?"}}