def __init__(self, doneEvent): def showDialog(avatar): model = loader.loadModel('phase_4/models/gui/ReturnPet') modelPos = (0, 0, -0.3) modelScale = (0.055, 0.055, 0.055) base.r = self DirectFrame.__init__(self, relief=None, state='normal', geom=model, geom_scale=modelScale, frameSize=(-1, 1, -1, 1), pos=modelPos, text=TTLocalizer.PetshopReturnConfirm % avatar.getName(), text_wordwrap=12, text_scale=TTLocalizer.PGUIreturnConfirm, text_pos=(0, 0.45), text_fg=text2Color) self.initialiseoptions(PetshopGUI.ReturnPetDlg) okImageList = (model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckRollover')) cancelImageList = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelRollover')) cancelIcon = model.find('**/CancelIcon') checkIcon = model.find('**/CheckIcon') self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, geom=cancelIcon, scale=modelScale, text=('', TTLocalizer.PetshopGoBack), text_pos=(-5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [0])) self.okButton = DirectButton(parent=self, relief=None, image=okImageList, geom=checkIcon, scale=modelScale, text=('', TTLocalizer.PetshopReturn), text_pos=(5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [1])) self.petView = self.attachNewNode('petView') self.petView.setPos(-0.15, 0, 0.8) self.petModel = Pet.Pet(forGui=1) self.petModel.setDNA(avatar.getDNA()) self.petModel.fitAndCenterHead(0.395, forGui=1) self.petModel.reparentTo(self.petView) self.petModel.setH(130) self.petModel.enterNeutralSad() model.removeNode() self.initialized = True return self.initialized = False self.petPanel = PetDetail.PetDetail(base.localAvatar.getPetId(), showDialog)
def updateMoodFromServer(self, callWhenDone=None): # call this to query the server for an up-to-date mood def handleGotDetails(avatar, callWhenDone=callWhenDone): self._grabMood(avatar) if callWhenDone: callWhenDone() PetDetail.PetDetail(self.doId, handleGotDetails)
def updateMoodFromServer(self, callWhenDone=None): def handleGotDetails(avatar, callWhenDone=callWhenDone): self._grabMood(avatar) if callWhenDone: callWhenDone() PetDetail.PetDetail(self.doId, handleGotDetails)
def __handleToPet(self): toonAvatar = self.avatar if base.cr.doId2do.get(toonAvatar.getDoId()): toonAvatar = base.cr.doId2do.get(toonAvatar.getDoId()) petAvatar = base.cr.doId2do.get(toonAvatar.getPetId()) self.disableAll() from toontown.pets import PetDetail PetDetail.PetDetail(toonAvatar.getPetId(), self.__petDetailsLoaded)
def __handleToPet(self): toonAvatar = self.avatar # if we have the friend in our cr it's more up to date and we should get the pet from that. if base.cr.doId2do.get(toonAvatar.getDoId()): toonAvatar = base.cr.doId2do.get(toonAvatar.getDoId()) petAvatar = base.cr.doId2do.get(toonAvatar.getPetId()) self.disableAll() from toontown.pets import PetDetail PetDetail.PetDetail(toonAvatar.getPetId(), self.__petDetailsLoaded)
def addPetToFriendsMap(self, callback=None): doId = base.localAvatar.getPetId() if not doId or doId in self.friendsMap: if callback: callback() def petDetailsCallback(petAvatar): petAvatar.announceGenerate() handle = PetHandle.PetHandle(petAvatar) self.friendsMap[doId] = handle petAvatar.disable() petAvatar.delete() if callback: callback() if self._proactiveLeakChecks: petAvatar.detectLeaks() PetDetail.PetDetail(doId, petDetailsCallback)