def updateHealthBar(self): if self.healthBar == None: return health = 1.0 - float(self.bossDamage) / float(self.bossMaxDamage) if health > 0.95: condition = 0 elif health > 0.7: condition = 1 elif health > 0.3: condition = 2 elif health > 0.05: condition = 3 elif health > 0.0: condition = 4 else: condition = 5 if self.healthCondition != condition: if condition == 4: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif condition == 5: if self.healthCondition == 4: taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition return
def updateHealthBar(self, hp): if not self.healthBar: return if hp > self.health: self.health = hp health = 0.0 try: health = float(hp) / float(self.maxHealth) except: pass if health > 0.95: condition = 0 elif health > 0.7: condition = 1 elif health > 0.3: condition = 2 elif health > 0.05: condition = 3 elif health > 0.0: condition = 4 else: condition = 5 if self.condition != condition: taskMgr.remove(self.taskName('blink-task')) if condition == 4: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.taskName('blink-task')) elif condition == 5: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.taskName('blink-task')) else: self.healthBar.setColor(SuitGlobals.healthColors[condition], 1) self.healthBarGlow.setColor(SuitGlobals.healthGlowColors[condition], 1) self.condition = condition
def updateHealthBar(self, hp, forceUpdate = 0): if hp > self.currHP: hp = self.currHP self.currHP -= hp health = float(self.currHP) / float(self.maxHP) if health > 0.95: condition = 0 elif health > 0.7: condition = 1 elif health > 0.3: condition = 2 elif health > 0.05: condition = 3 elif health > 0.0: condition = 4 else: condition = 5 if self.healthCondition != condition or forceUpdate: if condition == 4: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif condition == 5: if self.healthCondition == 4: taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): if not self.suit: return self.setHp(self.suit.getHP()) health = float(self.currHP) / float(self.maxHP) if health > 0.95: condition = 0 elif health > 0.9: condition = 1 elif health > 0.8: condition = 2 elif health > 0.7: condition = 3 #Yellow elif health > 0.6: condition = 4 elif health > 0.5: condition = 5 elif health > 0.3: condition = 6 #Orange elif health > 0.15: condition = 7 elif health > 0.05: condition = 8 #Red elif health > 0.0: condition = 9 #Blinking Red else: condition = 10 if self.healthCondition != condition: if condition == 9: self.blinkTask = self.uniqueName('blink-task') blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.blinkTask) elif condition == 10: if self.healthCondition == 9: self.blinkTask = self.uniqueName('blink-task') taskMgr.remove(self.blinkTask) self.blinkTask = None blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.blinkTask) else: if self.blinkTask: taskMgr.remove(self.blinkTask) self.blinkTask = None self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def enableInteractionButtons(self): self.notify.debug('enable buttons') proxTask = Task.loop(Task(self.__checkPetProximity), Task.pause(0.5)) taskMgr.add(proxTask, 'petpanel-proximity-check', priority=ToontownGlobals.PetPanelProximityPriority) self.__checkPetProximity()
def updateHealthBar(self): if not self.suit: return self.setHp(self.suit.getHP()) health = float(self.currHP) / float(self.maxHP) if health > 0.95: condition = 0 elif health > 0.9: condition = 1 elif health > 0.8: condition = 2 elif health > 0.7: condition = 3#Yellow elif health > 0.6: condition = 4 elif health > 0.5: condition = 5 elif health > 0.3: condition = 6#Orange elif health > 0.15: condition = 7 elif health > 0.05: condition = 8#Red elif health > 0.0: condition = 9#Blinking Red else: condition = 10 if self.healthCondition != condition: if condition == 9: self.blinkTask = self.uniqueName('blink-task') blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.blinkTask) elif condition == 10: if self.healthCondition == 9: self.blinkTask = self.uniqueName('blink-task') taskMgr.remove(self.blinkTask) self.blinkTask = None blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.blinkTask) else: if self.blinkTask: taskMgr.remove(self.blinkTask) self.blinkTask = None self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): condition = self.cog.healthCondition if condition == 4: self.blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task.pause(0.1)) taskMgr.add(self.blinkTask, self.uniqueName('blink-task')) else: taskMgr.remove(self.uniqueName('blink-task')) self.button.setColor(self.healthColors[condition], 1) self.glow.setColor(self.healthGlowColors[condition], 1)
def __checkUpdateColor(self, hp, maxhp): if self.bossBar: self.healthRatio = float(hp) / float(maxhp) if self.healthRatio > self.colorThresholds[0]: condition = 0 elif self.healthRatio > self.colorThresholds[1]: condition = 1 elif self.healthRatio > self.colorThresholds[2]: condition = 2 elif self.healthRatio > self.colorThresholds[3]: condition = 3 elif self.healthRatio > self.colorThresholds[4]: condition = 4 else: condition = 5 self.__applyNewColor(condition) if self.healthCondition != condition: if condition == 4: if self.healthCondition == 5: taskMgr.remove('bar-blink-task') self.isBlinking = False blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, 'bar-blink-task') self.isBlinking = True elif condition == 5: if self.healthCondition == 4: taskMgr.remove('bar-blink-task') self.isBlinking = False blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, 'bar-blink-task') self.isBlinking = True else: if self.isBlinking: taskMgr.remove('bar-blink-task') self.isBlinking = False self.healthCondition = condition
def updateHealthBar(self): health = float(float(self.hp) / float(self.maxHp)) if health < 1: self.corpMedallion.hide() self.healthBar.show() if health > 0.95: condition = 0 elif health > 0.7: condition = 1 elif health > 0.3: condition = 2 elif health > 0.05: condition = 3 elif health > 0: condition = 4 else: condition = 5 if (self.healthCondition != condition): if (condition == 4): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) base.taskMgr.add(blinkTask, 'blink-task') elif (condition == 5): if (self.healthCondition == 4): base.taskMgr.remove('blink-task') if (self.isDefeated == False): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) base.taskMgr.add(blinkTask, 'blink-task') self.isDefeated = True if not self.cog.hasPythonTag("Support"): roundInstance = render.getPythonTag('Round') wave = roundInstance.getCurrentWave() wave.setCogsDefeated(wave.getCogsDefeated() + 1) base.taskMgr.doMethodLater(1.5, self.setDefeated, 'Set Cog Defeated') else: self.healthBar.setColor(healthColors[condition], 1) self.healthBarGlow.setColor(healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): if self.healthBar == None: return health = 1.0 - float(self.bossDamage) / float(self.bossMaxDamage) if health > 0.95: condition = 0 elif health > 0.9: condition = 1 elif health > 0.8: condition = 2 elif health > 0.7: condition = 3 #Yellow elif health > 0.6: condition = 4 elif health > 0.5: condition = 5 elif health > 0.3: condition = 6 #Orange elif health > 0.15: condition = 7 elif health > 0.05: condition = 8 #Red elif health > 0.0: condition = 9 #Blinking Red else: condition = 10 if self.healthCondition != condition: if condition == 9: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif condition == 10: if self.healthCondition == 9: taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): condition = self.cog.healthCondition if condition == 9: self.blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task.pause(0.1)) taskMgr.add(self.blinkTask, self.uniqueName('blink-task')) elif condition == 10: taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: taskMgr.remove(self.uniqueName('blink-task')) if not self.button.isEmpty(): self.button.setColor(self.healthColors[condition], 1) if not self.glow.isEmpty(): self.glow.setColor(self.healthGlowColors[condition], 1) self.hp = self.cog.getHP() self.maxHp = self.cog.getMaxHP() self.hpText['text'] = str(self.hp) + '/' + str(self.maxHp)
def updateHealthBar(self, hp, forceUpdate=0): if (hp > self.currHP): hp = self.currHP self.currHP -= hp health = float(self.currHP) / float(self.maxHP) if (health > 0.95): condition = 0 elif (health > 0.7): condition = 1 elif (health > 0.3): condition = 2 elif (health > 0.05): condition = 3 elif (health > 0.0): # This should be blinking red condition = 4 else: # This should be blinking red even faster condition = 5 if (self.healthCondition != condition) or forceUpdate: if (condition == 4): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif (condition == 5): if (self.healthCondition == 4): taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def update(self, health, maxHealth): if self.isUpdating: taskMgr.remove('bar-smooth-update-task') self.isUpdating = False self.newHealth = health if self.newhealth < 0: self.newhealth = 0 if self.maxHealth != 0: if self.currentHealth != self.newHealth: smoothUpdateTask = Task.loop(Task(self.__smoothUpdate), Task.pause(0.01)) taskMgr.add(smoothUpdateTask, 'bar-smooth-update-task') self.isUpdating = True
def update(self, hp, maxHp): if self.isUpdating: taskMgr.remove('bar-smooth-update-task') self.isUpdating = False self.newHp = hp if self.newHp < 0: self.newHp = 0 if self.maxHp != 0: if self.currHp != self.newHp: smoothUpdateTask = Task.loop(Task(self.__smoothUpdate), Task.pause(0.01)) taskMgr.add(smoothUpdateTask, 'bar-smooth-update-task') self.isUpdating = True
def updateHealthBar(self): if self.healthBar == None: return health = 1.0 - float(self.bossDamage) / float(self.bossMaxDamage) if health > 0.95: condition = 0 elif health > 0.9: condition = 1 elif health > 0.8: condition = 2 elif health > 0.7: condition = 3#Yellow elif health > 0.6: condition = 4 elif health > 0.5: condition = 5 elif health > 0.3: condition = 6#Orange elif health > 0.15: condition = 7 elif health > 0.05: condition = 8#Red elif health > 0.0: condition = 9#Blinking Red else: condition = 10 if self.healthCondition != condition: if condition == 9: blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif condition == 10: if self.healthCondition == 9: taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): health = float(float(self.hp) / float(self.maxHp)) if health < 1: self.corpMedallion.hide() self.healthBar.show() if health > 0.95: condition = 0 elif health > 0.7: condition = 1 elif health > 0.3: condition = 2 elif health > 0.05: condition = 3 elif health > 0: condition = 4 else: condition = 5 if(self.healthCondition != condition): if(condition == 4): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) base.taskMgr.add(blinkTask, 'blink-task') elif(condition == 5): if(self.healthCondition == 4): base.taskMgr.remove('blink-task') if(self.isDefeated == False): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) base.taskMgr.add(blinkTask, 'blink-task') self.isDefeated = True if not self.cog.hasPythonTag("Support"): roundInstance = render.getPythonTag('Round') wave = roundInstance.getCurrentWave() wave.setCogsDefeated(wave.getCogsDefeated() + 1) base.taskMgr.doMethodLater(1.5, self.setDefeated, 'Set Cog Defeated') else: self.healthBar.setColor(healthColors[condition], 1) self.healthBarGlow.setColor(healthGlowColors[condition], 1) self.healthCondition = condition
def updateHealthBar(self): if self.healthBar == None: return health = 1.0 - (float(self.bossDamage) / float(self.bossMaxDamage)) if (health > 0.95): condition = 0 elif (health > 0.7): condition = 1 elif (health > 0.3): condition = 2 elif (health > 0.05): condition = 3 elif (health > 0.0): # This should be blinking red condition = 4 else: # This should be blinking red even faster condition = 5 if (self.healthCondition != condition): if (condition == 4): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) elif (condition == 5): if (self.healthCondition == 4): taskMgr.remove(self.uniqueName('blink-task')) blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, self.uniqueName('blink-task')) else: self.healthBar.setColor(self.healthColors[condition], 1) self.healthBarGlow.setColor(self.healthGlowColors[condition], 1) self.healthCondition = condition
def launchPresence(self): callbacks = { 'ready': self.readyCallback, 'disconnected': self.disconnectedCallback, 'joinGame': self.joinCallback, 'spectateGame': None, 'joinRequest': self.joinCallback, 'error': self.errorCallback } self.discordRpc.initialize(discordToken, callbacks=callbacks, log=True) self.updatePresence() updateTask = Task.loop(Task(self.updateConnection), Task.pause(1.0), Task(self.runCallbacks)) taskMgr.add(updateTask, 'update-presence-task') return
def enableInteractionButtons(self): self.notify.debug("enable buttons") proxTask = Task.loop(Task(self.__checkPetProximity), Task.pause(0.5)) taskMgr.add(proxTask, "petpanel-proximity-check", priority=ToontownGlobals.PetPanelProximityPriority) """ if pet is out of range, this would flash feed/scratch for a frame after feeding or scratching self.scratchButton['state'] = DGG.NORMAL self.feedButton['state'] = self.feedButtonState() self.callButton['state'] = DGG.NORMAL """ # instead, call this to set the button states self.__checkPetProximity()
def update(self, hp, forceUpdate = 0): if not self.geom: return condition = self.getHealthCondition(hp) if self.healthCondition != condition or forceUpdate: taskMgr.remove('blink-task-%s' % id(self)) if condition in (9, 10): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75 if condition == 9 else 0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, 'blink-task-%s' % id(self)) else: self.geom.setColor(HEALTH_COLORS[condition], 1) self.geomGlow.setColor(HEALTH_GLOW_COLORS[condition], 1) self.healthCondition = condition
def update(self, hp, forceUpdate = 0): if not self.geom: return condition = self.getHealthCondition(hp) if self.healthCondition != condition or forceUpdate: taskMgr.remove('blink-task-%s' % id(self)) if condition in (10, 11): blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75 if condition == 10 else 0.25), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(blinkTask, 'blink-task-%s' % id(self)) else: self.geom.setColor(HEALTH_COLORS[condition], 1) self.geomGlow.setColor(HEALTH_GLOW_COLORS[condition], 1) self.healthCondition = condition
def applyNewTrainLightTask(self): hideShowTrainLight = Task.loop(Task.pause(random.uniform(0.05, 1.5)), Task(self.hideTrainLightTask), Task.pause(0.1), Task(self.showTrainLightTask)) taskMgr.add(hideShowTrainLight, 'hide-show-train-light-task')
def __init__(self, avatar): self.notify.debug('Init(): doId=%s' % avatar.doId) distPet = base.cr.doId2do.get(avatar.doId) if distPet and not distPet.isProxy(): self.avatar = distPet self.petIsLocal = True else: self.avatar = avatar self.petIsLocal = False from toontown.friends import FriendsListPanel AvatarPanel.AvatarPanel.__init__(self, self.avatar, FriendsListPanel=FriendsListPanel) base.localAvatar.obscureFriendsListButton(1) base.panel = self gui = loader.loadModel('phase_3.5/models/gui/PetControlPannel') guiScale = 0.116 guiPos = (1.12, 0, 0.3) self.frame = DirectFrame(parent=aspect2dp, image=gui, scale=guiScale, pos=guiPos, relief=None) disabledImageColor = Vec4(0.6, 0.6, 0.6, 1) text0Color = Vec4(1, 1, 1, 1) text1Color = Vec4(0.5, 1, 0.5, 1) text2Color = Vec4(1, 1, 0.5, 1) text3Color = Vec4(0.6, 0.6, 0.6, 1) self.closeButton = DirectButton(parent=self.frame, image=(gui.find('**/CancelButtonUp'), gui.find('**/CancelButtonDown'), gui.find('**/CancelButtonRollover')), relief=None, command=self.__handleClose) self.feedButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonFeedUp'), gui.find('**/ButtonFeedDown'), gui.find('**/ButtonFeedRollover'), gui.find('**/ButtonFeedUp')), geom=gui.find('**/PetControlFeedIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelFeed, text_scale=TTLocalizer.PAPfeedButton, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_pos=(-0.5, 2.8), text_align=TextNode.ALeft, command=self.__handleFeed) if not self.petIsLocal: self.feedButton['state'] = DGG.DISABLED else: self.feedButton['state'] = self.feedButtonState() self.callButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonGoToUp'), gui.find('**/ButtonGoToDown'), gui.find('**/ButtonGoToRollover'), gui.find('**/ButtonGoToUp')), geom=gui.find('**/PetControlGoToIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelCall, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPcallButton, text_pos=(-0.5, 1.3), text_align=TextNode.ALeft, command=self.__handleCall) if not self.petIsLocal: self.callButton['state'] = DGG.DISABLED self.scratchButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonScratchUp'), gui.find('**/ButtonScratchDown'), gui.find('**/ButtonScratchRollover'), gui.find('**/ButtonScratchUp')), geom=gui.find('**/PetControlScratchIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelScratch, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPscratchButton, text_pos=(-0.5, 2.05), text_align=TextNode.ALeft, command=self.__handleScratch) if not self.petIsLocal: self.scratchButton['state'] = DGG.DISABLED self.ownerButton = DirectButton(parent=self.frame, image=(gui.find('**/PetControlToonButtonUp'), gui.find('**/PetControlToonButtonDown'), gui.find('**/PetControlToonButtonRollover')), geom=gui.find('**/PetControlToonIcon'), geom3_color=disabledImageColor, relief=None, image3_color=disabledImageColor, text=('', TTLocalizer.PetPanelOwner, TTLocalizer.PetPanelOwner, ''), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=TTLocalizer.PAPownerButton, text_pos=(0.3, 1.05), text_align=TextNode.ACenter, command=self.__handleToOwner) if self.avatar.getOwnerId() == base.localAvatar.doId: self.ownerButton['state'] = DGG.DISABLED toonGui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui') self.detailButton = DirectButton(parent=self.frame, image=(toonGui.find('**/ChtBx_BackBtn_UP'), toonGui.find('**/ChtBx_BackBtn_DN'), toonGui.find('**/ChtBx_BackBtn_Rllvr'), toonGui.find('**/ChtBx_BackBtn_UP')), relief=None, pos=(-1.3, 0, 0.67), image3_color=disabledImageColor, text=('', TTLocalizer.PetPanelDetail, TTLocalizer.PetPanelDetail, ''), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=0.05, text_pos=(0.05, 0.05), text_align=TextNode.ACenter, command=self.__handleDetail) self.detailButton.setScale(7.5) if not self.petIsLocal: self.detailButton['state'] = DGG.DISABLED gui.removeNode() toonGui.removeNode() self.petDetailPanel = None self.__fillPetInfo(self.avatar) self.accept('petNameChanged', self.__refreshPetInfo) self.accept('petStateUpdated', self.__refreshPetInfo) self.frame.show() if self.petIsLocal: proxTask = Task.loop(Task(self.__checkPetProximity), Task.pause(0.5)) taskMgr.add(proxTask, 'petpanel-proximity-check', priority=ToontownGlobals.PetPanelProximityPriority) if base.localAvatar.isLockedDown(): self.disableInteractionButtons() if self.petIsLocal: self.listenForInteractionDone() messenger.send('petPanelDone') if not self.petIsLocal and hasattr(self.avatar, 'updateMoodFromServer'): if self.avatar.doId != localAvatar.getPetId() or bboard.get(PetConstants.OurPetsMoodChangedKey, False): self.stateLabel['text'] = '' def refresh(self = self, av = self.avatar): bboard.remove(PetConstants.OurPetsMoodChangedKey) self.__refreshPetInfo(av) self.avatar.updateMoodFromServer(refresh) return
def __init__(self, avatar): """__init__(self)""" self.notify.debug("Init(): doId=%s" % avatar.doId) #determine if this avatar is in the same zone as the localtoon distPet = base.cr.doId2do.get(avatar.doId) if distPet and not distPet.isProxy(): self.avatar = distPet self.petIsLocal = True else: self.avatar = avatar self.petIsLocal = False from toontown.friends import FriendsListPanel AvatarPanel.AvatarPanel.__init__(self, self.avatar, FriendsListPanel=FriendsListPanel) base.localAvatar.obscureFriendsListButton(1) base.panel = self gui = loader.loadModel("phase_3.5/models/gui/PetControlPannel") guiScale = 0.116 guiPos = (1.12, 0, 0.30) self.frame = DirectFrame( parent=aspect2dp, image=gui, scale=guiScale, pos=guiPos, relief=None, ) disabledImageColor = Vec4(.6, .6, .6, 1) text0Color = Vec4(1, 1, 1, 1) text1Color = Vec4(0.5, 1, 0.5, 1) text2Color = Vec4(1, 1, 0.5, 1) text3Color = Vec4(.6, .6, .6, 1) self.closeButton = DirectButton( parent=self.frame, image=( gui.find("**/CancelButtonUp"), gui.find("**/CancelButtonDown"), gui.find("**/CancelButtonRollover"), ), relief=None, command=self.__handleClose, ) self.feedButton = DirectButton( parent=self.frame, image=( gui.find("**/ButtonFeedUp"), gui.find("**/ButtonFeedDown"), gui.find("**/ButtonFeedRollover"), gui.find("**/ButtonFeedUp"), ), geom=gui.find("**/PetControlFeedIcon"), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelFeed, text_scale=TTLocalizer.PAPfeedButton, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_pos=(-0.5, 2.8), text_align=TextNode.ALeft, command=self.__handleFeed, ) if not self.petIsLocal: self.feedButton['state'] = DGG.DISABLED else: self.feedButton['state'] = self.feedButtonState() self.callButton = DirectButton( parent=self.frame, image=( gui.find("**/ButtonGoToUp"), gui.find("**/ButtonGoToDown"), gui.find("**/ButtonGoToRollover"), gui.find("**/ButtonGoToUp"), ), geom=gui.find("**/PetControlGoToIcon"), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelCall, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPcallButton, text_pos=(-0.5, 1.3), text_align=TextNode.ALeft, command=self.__handleCall, ) if not self.petIsLocal: self.callButton['state'] = DGG.DISABLED self.scratchButton = DirectButton( parent=self.frame, image=( gui.find("**/ButtonScratchUp"), gui.find("**/ButtonScratchDown"), gui.find("**/ButtonScratchRollover"), gui.find("**/ButtonScratchUp"), ), geom=gui.find("**/PetControlScratchIcon"), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelScratch, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPscratchButton, text_pos=(-0.5, 2.05), text_align=TextNode.ALeft, command=self.__handleScratch, ) if not self.petIsLocal: self.scratchButton['state'] = DGG.DISABLED self.ownerButton = DirectButton( parent=self.frame, image=( gui.find("**/PetControlToonButtonUp"), gui.find("**/PetControlToonButtonDown"), gui.find("**/PetControlToonButtonRollover"), ), geom=gui.find("**/PetControlToonIcon"), geom3_color=disabledImageColor, relief=None, image3_color=disabledImageColor, text=("", TTLocalizer.PetPanelOwner, TTLocalizer.PetPanelOwner, ""), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=TTLocalizer.PAPownerButton, text_pos=(0.3, 1.05), text_align=TextNode.ACenter, command=self.__handleToOwner, ) if self.avatar.getOwnerId() == base.localAvatar.doId: self.ownerButton['state'] = DGG.DISABLED toonGui = loader.loadModel("phase_3.5/models/gui/avatar_panel_gui") self.detailButton = DirectButton( parent=self.frame, image=( toonGui.find("**/ChtBx_BackBtn_UP"), toonGui.find("**/ChtBx_BackBtn_DN"), toonGui.find("**/ChtBx_BackBtn_Rllvr"), toonGui.find("**/ChtBx_BackBtn_UP"), ), relief=None, pos=(-1.3, 0, 0.67), image3_color=disabledImageColor, text=("", TTLocalizer.PetPanelDetail, TTLocalizer.PetPanelDetail, ""), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=0.05, text_pos=(0.05, 0.05), text_align=TextNode.ACenter, command=self.__handleDetail, ) self.detailButton.setScale(7.5) if (not self.petIsLocal): self.detailButton['state'] = DGG.DISABLED gui.removeNode() toonGui.removeNode() self.petDetailPanel = None self.__fillPetInfo(self.avatar) self.accept("petNameChanged", self.__refreshPetInfo) self.accept("petStateUpdated", self.__refreshPetInfo) self.frame.show() if self.petIsLocal: #if this pet is real, set up a task to check his proximity proxTask = Task.loop(Task(self.__checkPetProximity), Task.pause(0.5)) taskMgr.add(proxTask, "petpanel-proximity-check", priority=ToontownGlobals.PetPanelProximityPriority) if base.localAvatar.isLockedDown(): self.disableInteractionButtons() if self.petIsLocal: self.listenForInteractionDone() messenger.send("petPanelDone") # refresh the pet info if ((not self.petIsLocal) and hasattr(self.avatar, 'updateMoodFromServer')): # can we use previously-cached mood info? Only do this for # localAv's pet. We can't reliably know if the mood of someone # else's pet has changed since we last queried their info... if (self.avatar.doId != localAvatar.getPetId() or bboard.get(PetConstants.OurPetsMoodChangedKey, False)): # clear out the state text, since it may be stale and we'll be # setting it to a correct string in a moment self.stateLabel['text'] = '' def refresh(self=self, av=self.avatar): # clear the 'mood dirty' flag for localAv's pet bboard.remove(PetConstants.OurPetsMoodChangedKey) self.__refreshPetInfo(av) self.avatar.updateMoodFromServer(refresh)
def __init__(self, avatar): self.notify.debug('Init(): doId=%s' % avatar.doId) distPet = base.cr.doId2do.get(avatar.doId) if distPet and not distPet.isProxy(): self.avatar = distPet self.petIsLocal = True else: self.avatar = avatar self.petIsLocal = False from toontown.friends import FriendsListPanel AvatarPanel.AvatarPanel.__init__(self, self.avatar, FriendsListPanel=FriendsListPanel) base.localAvatar.obscureFriendsListButton(1) base.panel = self gui = loader.loadModel('phase_3.5/models/gui/PetControlPannel') guiScale = 0.116 guiPos = (-0.213, 0, -0.70) self.frame = DirectFrame(parent=base.a2dTopRight, image=gui, scale=guiScale, pos=guiPos, relief=None) disabledImageColor = Vec4(0.6, 0.6, 0.6, 1) text0Color = Vec4(1, 1, 1, 1) text1Color = Vec4(0.5, 1, 0.5, 1) text2Color = Vec4(1, 1, 0.5, 1) text3Color = Vec4(0.6, 0.6, 0.6, 1) self.closeButton = DirectButton(parent=self.frame, image=(gui.find('**/CancelButtonUp'), gui.find('**/CancelButtonDown'), gui.find('**/CancelButtonRollover')), relief=None, command=self.__handleClose) self.feedButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonFeedUp'), gui.find('**/ButtonFeedDown'), gui.find('**/ButtonFeedRollover'), gui.find('**/ButtonFeedUp')), geom=gui.find('**/PetControlFeedIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelFeed, text_scale=TTLocalizer.PAPfeedButton, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_pos=(-0.5, 2.8), text_align=TextNode.ALeft, command=self.__handleFeed) if not self.petIsLocal: self.feedButton['state'] = DGG.DISABLED else: self.feedButton['state'] = self.feedButtonState() self.callButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonGoToUp'), gui.find('**/ButtonGoToDown'), gui.find('**/ButtonGoToRollover'), gui.find('**/ButtonGoToUp')), geom=gui.find('**/PetControlGoToIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelCall, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPcallButton, text_pos=(-0.5, 1.3), text_align=TextNode.ALeft, command=self.__handleCall) if not self.petIsLocal: self.callButton['state'] = DGG.DISABLED self.scratchButton = DirectButton(parent=self.frame, image=(gui.find('**/ButtonScratchUp'), gui.find('**/ButtonScratchDown'), gui.find('**/ButtonScratchRollover'), gui.find('**/ButtonScratchUp')), geom=gui.find('**/PetControlScratchIcon'), geom3_color=disabledImageColor, image3_color=disabledImageColor, relief=None, text=TTLocalizer.PetPanelScratch, text0_fg=text0Color, text1_fg=text1Color, text2_fg=text2Color, text3_fg=text3Color, text_scale=TTLocalizer.PAPscratchButton, text_pos=(-0.5, 2.05), text_align=TextNode.ALeft, command=self.__handleScratch) if not self.petIsLocal: self.scratchButton['state'] = DGG.DISABLED self.ownerButton = DirectButton(parent=self.frame, image=(gui.find('**/PetControlToonButtonUp'), gui.find('**/PetControlToonButtonDown'), gui.find('**/PetControlToonButtonRollover')), geom=gui.find('**/PetControlToonIcon'), geom3_color=disabledImageColor, relief=None, image3_color=disabledImageColor, text=('', TTLocalizer.PetPanelOwner, TTLocalizer.PetPanelOwner, ''), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=TTLocalizer.PAPownerButton, text_pos=(0.3, 1.05), text_align=TextNode.ACenter, command=self.__handleToOwner) if self.avatar.getOwnerId() == base.localAvatar.doId: self.ownerButton['state'] = DGG.DISABLED toonGui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui') self.detailButton = DirectButton(parent=self.frame, image=(toonGui.find('**/ChtBx_BackBtn_UP'), toonGui.find('**/ChtBx_BackBtn_DN'), toonGui.find('**/ChtBx_BackBtn_Rllvr'), toonGui.find('**/ChtBx_BackBtn_UP')), relief=None, pos=(-1.3, 0, 0.67), image3_color=disabledImageColor, text=('', TTLocalizer.PetPanelDetail, TTLocalizer.PetPanelDetail, ''), text_fg=text2Color, text_shadow=(0, 0, 0, 1), text_scale=0.05, text_pos=(0.05, 0.05), text_align=TextNode.ACenter, command=self.__handleDetail) self.detailButton.setScale(7.5) if not self.petIsLocal: self.detailButton['state'] = DGG.DISABLED gui.removeNode() toonGui.removeNode() self.petDetailPanel = None self.__fillPetInfo(self.avatar) self.accept('petNameChanged', self.__refreshPetInfo) self.accept('petStateUpdated', self.__refreshPetInfo) self.frame.show() if self.petIsLocal: proxTask = Task.loop(Task(self.__checkPetProximity), Task.pause(0.5)) taskMgr.add(proxTask, 'petpanel-proximity-check', priority=ToontownGlobals.PetPanelProximityPriority) if base.localAvatar.isLockedDown(): self.disableInteractionButtons() if self.petIsLocal: self.listenForInteractionDone() messenger.send('petPanelDone') if not self.petIsLocal and hasattr(self.avatar, 'updateMoodFromServer'): if self.avatar.doId != localAvatar.getPetId() or bboard.get(PetConstants.OurPetsMoodChangedKey, False): self.stateLabel['text'] = '' def refresh(self = self, av = self.avatar): bboard.remove(PetConstants.OurPetsMoodChangedKey) self.__refreshPetInfo(av) self.avatar.updateMoodFromServer(refresh) return
def startBlinkTask(self): self.blinkTask = Task.loop(Task(self.__blinkRed), Task.pause(0.75), Task(self.__blinkGray), Task.pause(0.1)) taskMgr.add(self.blinkTask, 'bosshealthbar-blink-task')