2015-03-03 16:10:12 -06:00
|
|
|
from direct.gui.DirectGui import *
|
2015-06-23 18:11:48 -05:00
|
|
|
from panda3d.core import *
|
2015-03-03 16:10:12 -06:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
from direct.fsm import StateData
|
|
|
|
from toontown.toonbase import TTLocalizer
|
|
|
|
from toontown.toontowngui import TTDialog
|
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
from toontown.suit import SuitDNA
|
|
|
|
from toontown.suit import Suit
|
|
|
|
from toontown.battle import SuitBattleGlobals
|
|
|
|
from toontown.toon import NPCToons
|
|
|
|
|
|
|
|
class SummonCogDialog(DirectFrame, StateData.StateData):
|
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('SummonCogDialog')
|
|
|
|
notify.setInfo(True)
|
|
|
|
|
|
|
|
def __init__(self, suitIndex):
|
2015-07-07 13:16:55 -05:00
|
|
|
DirectFrame.__init__(self, parent=aspect2dp, pos=(0, 0, 0.3), relief=None, image=DGG.getDefaultDialogGeom(), image_scale=(1.6, 1, 1.07), image_pos=(0, 0, 0.09), image_color=ToontownGlobals.GlobalDialogColor, text=TTLocalizer.SummonDlgTitle, text_scale=0.12, text_pos=(0, 0.5), borderWidth=(0.01, 0.01), sortOrder=NO_FADE_SORT_INDEX)
|
2015-03-03 16:10:12 -06:00
|
|
|
StateData.StateData.__init__(self, 'summon-cog-done')
|
|
|
|
self.initialiseoptions(SummonCogDialog)
|
|
|
|
self.suitIndex = suitIndex
|
|
|
|
base.summonDialog = self
|
|
|
|
self.popup = None
|
|
|
|
self.suitName = SuitDNA.suitHeadTypes[self.suitIndex]
|
|
|
|
self.suitFullName = SuitBattleGlobals.SuitAttributes[self.suitName]['name']
|
|
|
|
return
|
|
|
|
|
|
|
|
def unload(self):
|
|
|
|
if self.isLoaded == 0:
|
|
|
|
return None
|
|
|
|
self.isLoaded = 0
|
|
|
|
self.exit()
|
|
|
|
DirectFrame.destroy(self)
|
|
|
|
return None
|
|
|
|
|
|
|
|
def load(self):
|
|
|
|
if self.isLoaded == 1:
|
|
|
|
return None
|
|
|
|
self.isLoaded = 1
|
|
|
|
gui = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
|
|
|
|
guiButton = loader.loadModel('phase_3/models/gui/quit_button')
|
|
|
|
self.head = Suit.attachSuitHead(self, self.suitName)
|
|
|
|
z = self.head.getZ()
|
2015-07-07 13:16:55 -05:00
|
|
|
self.head.setPos(-0.4, -0.1, z + 0.14)
|
|
|
|
self.suitLabel = DirectLabel(parent=self, relief=None, text=self.suitFullName, text_font=ToontownGlobals.getSuitFont(), pos=(-0.4, 0, -0.085), scale=0.07)
|
2015-03-03 16:10:12 -06:00
|
|
|
closeButtonImage = (gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr'))
|
|
|
|
buttonImage = (guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR'))
|
|
|
|
disabledColor = Vec4(0.5, 0.5, 0.5, 1)
|
2015-07-07 13:16:55 -05:00
|
|
|
base.cr.lmao = self
|
|
|
|
self.summonBuildingButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton1, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.06, text_pos=(0, -0.01), pos=(0.3, 0, 0.35), command=self.issueSummons, extraArgs=['building'])
|
|
|
|
self.summonInvasionButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton2, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.06, text_pos=(0, -0.01), pos=(0.3, 0, 0.225), command=self.issueSummons, extraArgs=['invasion'])
|
|
|
|
self.summonCogdoButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton3, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.06, text_pos=(0, -0.01), pos=(0.3, 0, 0.1), command=self.issueSummons, extraArgs=['cogdo'])
|
|
|
|
self.summonSkelInvasionButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton4, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.051, text_pos=(0, -0.01), pos=(0.3, 0, -0.025), command=self.issueSummons, extraArgs=['skelinvasion'])
|
|
|
|
self.summonWaiterInvasionButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton5, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.056, text_pos=(0, -0.01), pos=(0.3, 0, -0.15), command=self.issueSummons, extraArgs=['waiterinvasion'])
|
|
|
|
self.summonV2InvasionButton = DirectButton(parent=self, relief=None, text=TTLocalizer.SummonDlgButton6, image=buttonImage, image_scale=(1.7, 1, 1), image3_color=disabledColor, text_scale=0.048, text_pos=(0, -0.01), pos=(0.3, 0, -0.275), command=self.issueSummons, extraArgs=['v2invasion'])
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel = DirectLabel(parent=self, relief=None, text='', text_wordwrap=12, pos=(0.3, 0, 0.3), scale=0.07)
|
2015-07-07 13:16:55 -05:00
|
|
|
self.cancel = DirectButton(parent=self, relief=None, image=closeButtonImage, pos=(0.7, 0, -0.366), command=self.__cancel)
|
2015-03-03 16:10:12 -06:00
|
|
|
gui.removeNode()
|
|
|
|
guiButton.removeNode()
|
|
|
|
self.hide()
|
|
|
|
return
|
|
|
|
|
|
|
|
def enter(self):
|
|
|
|
if self.isEntered == 1:
|
|
|
|
return None
|
|
|
|
self.isEntered = 1
|
|
|
|
if self.isLoaded == 0:
|
|
|
|
self.load()
|
|
|
|
self.disableButtons()
|
|
|
|
self.enableButtons()
|
|
|
|
self.popup = None
|
|
|
|
base.transitions.fadeScreen(0.5)
|
|
|
|
self.show()
|
|
|
|
return
|
|
|
|
|
|
|
|
def exit(self):
|
|
|
|
if self.isEntered == 0:
|
|
|
|
return None
|
|
|
|
self.isEntered = 0
|
|
|
|
self.cleanupDialogs()
|
|
|
|
base.transitions.noTransitions()
|
|
|
|
self.ignoreAll()
|
|
|
|
self.hide()
|
|
|
|
messenger.send(self.doneEvent, [])
|
|
|
|
return None
|
|
|
|
|
|
|
|
def cleanupDialogs(self):
|
|
|
|
self.head = None
|
|
|
|
if self.popup != None:
|
|
|
|
self.popup.cleanup()
|
|
|
|
self.popup = None
|
|
|
|
return
|
|
|
|
|
|
|
|
def cogSummonsDone(self, returnCode, suitIndex, buildingId):
|
|
|
|
self.cancel['state'] = DGG.NORMAL
|
2015-05-29 08:46:27 -05:00
|
|
|
if self.summonsType == 'building' or self.summonsType == 'cogdo':
|
2015-03-03 16:10:12 -06:00
|
|
|
if returnCode == 'success':
|
|
|
|
building = base.cr.doId2do.get(buildingId)
|
|
|
|
dnaStore = base.cr.playGame.dnaStore
|
|
|
|
buildingTitle = dnaStore.getTitleFromBlockNumber(building.block)
|
|
|
|
buildingInteriorZone = building.zoneId + 500 + building.block
|
|
|
|
npcName = TTLocalizer.SummonDlgShopkeeper
|
|
|
|
npcId = NPCToons.zone2NpcDict.get(buildingInteriorZone)
|
|
|
|
if npcId:
|
|
|
|
npcName = NPCToons.getNPCName(npcId[0])
|
|
|
|
if buildingTitle:
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgBldgSuccess % (npcName, buildingTitle)
|
2015-03-03 16:10:12 -06:00
|
|
|
else:
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgBldgSuccess2
|
2015-03-03 16:10:12 -06:00
|
|
|
elif returnCode == 'badlocation':
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgBldgBadLoc
|
2015-03-03 16:10:12 -06:00
|
|
|
elif returnCode == 'fail':
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgInvasionFail
|
|
|
|
elif returnCode == 'disabled':
|
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgBldgNoCogdos
|
|
|
|
elif self.summonsType.endswith('invasion'):
|
2015-03-03 16:10:12 -06:00
|
|
|
if returnCode == 'success':
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgInvasionSuccess
|
2015-03-03 16:10:12 -06:00
|
|
|
elif returnCode == 'busy':
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgInvasionBusy % self.suitFullName
|
2015-03-03 16:10:12 -06:00
|
|
|
elif returnCode == 'fail':
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgInvasionFail
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def hideSummonButtons(self):
|
|
|
|
self.summonBuildingButton.hide()
|
|
|
|
self.summonInvasionButton.hide()
|
2015-05-29 08:46:27 -05:00
|
|
|
self.summonCogdoButton.hide()
|
2015-07-07 13:16:55 -05:00
|
|
|
self.summonSkelInvasionButton.hide()
|
|
|
|
self.summonWaiterInvasionButton.hide()
|
2015-05-29 08:46:27 -05:00
|
|
|
self.summonV2InvasionButton.hide()
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def issueSummons(self, summonsType):
|
2015-05-29 08:46:27 -05:00
|
|
|
if summonsType == 'building' or summonsType == 'cogdo':
|
|
|
|
text = TTLocalizer.SummonDlgBuildingConf
|
2015-03-03 16:10:12 -06:00
|
|
|
elif summonsType == 'invasion':
|
2015-05-29 08:46:27 -05:00
|
|
|
text = TTLocalizer.SummonDlgInvasionConf
|
2015-07-07 13:16:55 -05:00
|
|
|
elif summonsType == 'skelinvasion':
|
|
|
|
text = TTLocalizer.SummonDlgSkelInvasionConf
|
|
|
|
elif summonsType == 'waiterinvasion':
|
|
|
|
text = TTLocalizer.SummonDlgWaiterInvasionConf
|
2015-05-29 08:46:27 -05:00
|
|
|
elif summonsType == 'v2invasion':
|
|
|
|
text = TTLocalizer.SummonDlgV2InvasionConf
|
2015-03-03 16:10:12 -06:00
|
|
|
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 doIssueSummonsText(self):
|
|
|
|
self.disableButtons()
|
2015-05-29 08:46:27 -05:00
|
|
|
self.statusLabel['text'] = TTLocalizer.SummonDlgDelivering
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def disableButtons(self):
|
|
|
|
self.summonBuildingButton['state'] = DGG.DISABLED
|
|
|
|
self.summonInvasionButton['state'] = DGG.DISABLED
|
2015-05-29 08:46:27 -05:00
|
|
|
self.summonCogdoButton['state'] = DGG.DISABLED
|
2015-07-07 13:16:55 -05:00
|
|
|
self.summonSkelInvasionButton['state'] = DGG.DISABLED
|
|
|
|
self.summonWaiterInvasionButton['state'] = DGG.DISABLED
|
2015-05-29 08:46:27 -05:00
|
|
|
self.summonV2InvasionButton['state'] = DGG.DISABLED
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def enableButtons(self):
|
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'building'):
|
|
|
|
self.summonBuildingButton['state'] = DGG.NORMAL
|
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'invasion'):
|
|
|
|
self.summonInvasionButton['state'] = DGG.NORMAL
|
2015-05-29 08:46:27 -05:00
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'cogdo'):
|
|
|
|
self.summonCogdoButton['state'] = DGG.NORMAL
|
2015-07-07 13:16:55 -05:00
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'skelinvasion'):
|
|
|
|
self.summonSkelInvasionButton['state'] = DGG.NORMAL
|
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'waiterinvasion'):
|
|
|
|
self.summonWaiterInvasionButton['state'] = DGG.NORMAL
|
2015-05-29 08:46:27 -05:00
|
|
|
if base.localAvatar.hasCogSummons(self.suitIndex, 'v2invasion'):
|
|
|
|
self.summonV2InvasionButton['state'] = DGG.NORMAL
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def __cancel(self):
|
|
|
|
self.exit()
|