def createFrame(self,
                 skillId,
                 skillPts,
                 upgradeMode=0,
                 freeLock=False,
                 showIcon=True):
     skillRank = max(0, skillPts - 1)
     if skillId in self.skillFrames:
         button = self.skillFrames[skillId]
         showUpgrade = upgradeMode and showIcon
         button.setShowUpgrade(showUpgrade)
         button.setShowIcon(showIcon)
         button.setShowLock(freeLock)
         button.show()
     else:
         button = SkillButton(skillId,
                              self.addPoint,
                              0,
                              skillRank,
                              showHelp=True,
                              showIcon=showIcon,
                              showLock=freeLock)
         showUpgrade = upgradeMode and showIcon
         button.setShowUpgrade(showUpgrade)
         button.reparentTo(self)
         self.skillFrames[skillId] = button
     button.skillButton['image_scale'] = 0.12
     if skillPts == 1:
         self.skillFrames[skillId]['text_fg'] = (0.5, 0.5, 0.5, 1)
         self.skillFrames[skillId].skillButton.setColorScale(1, 1, 1, 0.5)
     else:
         self.skillFrames[skillId]['text_fg'] = (1, 1, 1, 1)
         self.skillFrames[skillId].skillButton.clearColorScale()
Example #2
0
 def createFrame(self, skillId, skillPts, upgradeMode = 0, freeLock = False, showIcon = True):
     skillRank = max(0, skillPts - 1)
     if skillId in self.skillFrames:
         button = self.skillFrames[skillId]
         if upgradeMode:
             pass
         showUpgrade = showIcon
         button.setShowUpgrade(showUpgrade)
         button.setShowIcon(showIcon)
         button.setShowLock(freeLock)
         button.show()
     else:
         button = SkillButton(skillId, self.addPoint, 0, skillRank, showHelp = True, showIcon = showIcon, showLock = freeLock)
         if upgradeMode:
             pass
         showUpgrade = showIcon
         button.setShowUpgrade(showUpgrade)
         button.reparentTo(self)
         self.skillFrames[skillId] = button
     button.skillButton['image_scale'] = 0.12
     if skillPts == 1:
         self.skillFrames[skillId]['text_fg'] = (0.5, 0.5, 0.5, 1)
         self.skillFrames[skillId].skillButton.setColorScale(1, 1, 1, 0.5)
     else:
         self.skillFrames[skillId]['text_fg'] = (1, 1, 1, 1)
         self.skillFrames[skillId].skillButton.clearColorScale()
 def rePanel(self, inventory):
     if not self.showing:
         self.needRefresh = 1
         return None
     
     skillTokens = {
         InventoryType.CutlassToken: (ItemGlobals.RUSTY_CUTLASS,),
         InventoryType.PistolToken: (ItemGlobals.FLINTLOCK_PISTOL,),
         InventoryType.DollToken: (ItemGlobals.VOODOO_DOLL,),
         InventoryType.DaggerToken: (ItemGlobals.BASIC_DAGGER,),
         InventoryType.GrenadeToken: (ItemGlobals.GRENADE_POUCH,),
         InventoryType.WandToken: (ItemGlobals.CURSED_STAFF,) }
     zIndex = 1
     for skillTokenKey in TOKEN_LIST:
         quantity = 0
         if localAvatar.getInventory().stacks.get(skillTokenKey):
             quantity = 1
         
         skillData = skillTokens[skillTokenKey]
         weaponId = skillData[0]
         key = None
         panel = WeaponPanel.WeaponPanel((weaponId, quantity), key)
         panel.reparentTo(self)
         panel.setZ(PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999 - zIndex * panel.height)
         zIndex += 1
         repCat = WeaponGlobals.getRepId(weaponId)
         self.weaponPanels[repCat] = panel
         self.ignore('inventoryQuantity-%s' % inventory.getDoId())
         self.acceptOnce('inventoryQuantity-%s-%s' % (inventory.getDoId(), skillTokenKey), self.refreshList)
     
     repIcon_gui = loader.loadModel('models/textureCards/skillIcons')
     repIcon = repIcon_gui.find('**/box_base')
     if config.GetBool('want-fishing-game', 0):
         self.fishingIcon = GuiButton(pos = (0.16600000000000001, 0, 0.044999999999999998 + (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999) - zIndex * panel.height), helpText = PLocalizer.FishingRepDescription, helpOpaque = True, image = (repIcon, repIcon, repIcon, repIcon), image_scale = (0.14399999999999999, 0.14399999999999999, 0.14399999999999999))
         fishIconCard = loader.loadModel('models/textureCards/fishing_icons')
         inv = localAvatar.getInventory()
         fishingChangeMsg = InventoryGlobals.getCategoryQuantChangeMsg(inv.doId, InventoryType.FishingRod)
         if self.fishingChangeMsg:
             self.ignore(fishingChangeMsg)
         
         self.fishingChangeMsg = fishingChangeMsg
         self.acceptOnce(fishingChangeMsg, self.refreshList)
         rodIcons = [
             'pir_t_gui_fsh_smRodIcon',
             'pir_t_gui_fsh_mdRodIcon',
             'pir_t_gui_fsh_lgRodIcon']
         rodLvl = inv.getStackQuantity(InventoryType.FishingRod)
         rodIcon = rodIcons[rodLvl - 1]
         rodText = PLocalizer.FishingRodNames[rodLvl]
         if rodLvl >= 1:
             self.fishingIcon['geom'] = fishIconCard.find('**/' + rodIcon)
         
         self.fishingIcon['geom_scale'] = 0.10000000000000001
         self.fishingIcon['geom_pos'] = (0, 0, 0)
         self.fishingIcon.reparentTo(self)
         fishingRepValue = localAvatar.getInventory().getReputation(InventoryType.FishingRep)
         self.fishingRepMeter = ReputationMeter(InventoryType.FishingRep, width = 0.66000000000000003)
         self.fishingRepMeter.setPos(0.62, 0, 0.041000000000000002 + (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999) - zIndex * panel.height)
         self.fishingRepMeter.update(fishingRepValue)
         self.fishingRepMeter.reparentTo(self)
         self.fishingRepMeter.flattenLight()
         self.fishingPoleName = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = rodText, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.28999999999999998, 0, -0.0050000000000000001 + (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999) - 7 * panel.height), text_font = PiratesGlobals.getInterfaceFont())
         self.fishingPoleName.reparentTo(self)
         zIndex += 1
     
     iconCard = loader.loadModel('models/textureCards/skillIcons')
     if config.GetBool('want-potion-game', 0):
         self.potionIcon = GuiButton(pos = (0.16600000000000001, 0, 0.044999999999999998 + (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999) - zIndex * panel.height), helpText = PLocalizer.PotionRepDescription, helpOpaque = True, image = (repIcon, repIcon, repIcon, repIcon), image_scale = (0.14399999999999999, 0.14399999999999999, 0.14399999999999999))
         self.potionIcon['geom'] = iconCard.find('**/pir_t_gui_pot_base')
         self.potionIcon['geom_scale'] = 0.10000000000000001
         self.potionIcon['geom_pos'] = (0, 0, 0)
         self.potionIcon.reparentTo(self)
         potionRepValue = localAvatar.getInventory().getReputation(InventoryType.PotionsRep)
         self.potionRepMeter = ReputationMeter(InventoryType.PotionsRep, width = 0.66000000000000003)
         self.potionRepMeter.setPos(0.62, 0, 0.041000000000000002 + (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999) - zIndex * panel.height)
         self.potionRepMeter.update(potionRepValue)
         self.potionRepMeter.reparentTo(self)
         self.potionRepMeter.flattenLight()
         zIndex += 1
     
     items = dict(map(lambda x: (x.getType(), x.getCount()), inventory.getConsumables().values()))
     possibleItems = ItemGlobals.getAllHealthIds()
     havePorky = items.get(ItemGlobals.ROAST_PORK)
     if not havePorky and ItemGlobals.ROAST_PORK in possibleItems:
         possibleItems.remove(ItemGlobals.ROAST_PORK)
     
     offset = 0
     if base.config.GetBool('want-potion-game', 0):
         items = inventory.getConsumables()
         listLength = len(InventoryType.PotionMinigamePotions)
         count = 0
         for i in range(listLength):
             tonicId = InventoryType.PotionMinigamePotions[i]
             if items.get(tonicId):
                 button = SkillButton(tonicId, self.tonicCallback, items.get(tonicId), showQuantity = True, showHelp = True, showRing = True)
                 button.skillButton['geom_scale'] = 0.080000000000000002
                 x = 0.16 * (count % 6) + -1.2
                 z = 1.0 - int(count / 6) * 0.16
                 button.setPos(x, 0, z)
                 button.reparentTo(self)
                 self.tonicButtons[tonicId] = button
                 count += 1
                 continue
Example #4
0
 def updateSkillTray(self, rep, weaponMode, callback = None, hideFirst = True):
     if rep == InventoryType.MeleeRep:
         return None
     
     if not callback:
         callback = localAvatar.guiMgr.combatTray.triggerSkillTraySkill
     
     if taskMgr.hasTaskNamed('updateSkillTray'):
         taskMgr.remove('updateSkillTray')
     
     if self.skillTrayState and hideFirst:
         self.hideSkillTray()
         taskMgr.doMethodLater(0.75, self.updateSkillTray, 'updateSkillTray', extraArgs = [
             rep,
             weaponMode,
             callback])
         return None
     
     text = PLocalizer.InventoryTypeNames.get(rep, 'Unknown')
     for i in range(self.numberOfItems):
         self.tray[i + 1].destroy()
     
     self.tray = { }
     if self.repMeter:
         self.repMeter.destroy()
     
     self.rep = rep
     self.weaponMode = weaponMode
     self.callback = callback
     linkedSkillIds = { }
     linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
     for skillId in linkedSkills:
         realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
         linkedSkillIds[realSkillId] = skillId
     
     skillMap = []
     self.origMap = getAllSkills(self.rep, 2, wantWeaponSkill = 1)
     for i in range(len(self.origMap)):
         skillMap.append(self.origMap[i][0])
     
     self.traySkillMap = skillMap
     self.numberOfItems = len(self.traySkillMap)
     self.skillTray.setX(0)
     if self.rep != InventoryType.DefenseCannonRep:
         self.repMeter = ReputationMeter(self.rep, width = 0.69999999999999996)
         self.repMeter.setScale(1.1499999999999999, 1.1499999999999999, 1.1499999999999999)
         self.repMeter.reparentTo(self.skillTray)
         self.repMeter.setCategory(self.rep)
     
     inv = base.localAvatar.getInventory()
     if inv is None:
         return None
     
     if self.repMeter:
         self.repMeter.update(inv.getReputation(self.rep))
     
     x = 0.0
     offset = 0.0
     for i in range(self.numberOfItems):
         if self.origMap[i][1] == False:
             locked = False
             if locked:
                 image = (self.SkillIcons.find('**/base'), self.SkillIcons.find('**/base_down'), self.SkillIcons.find('**/base_over'))
             else:
                 image = self.SkillIcons.find('**/base')
             button = DirectButton(parent = self.skillTray, relief = None, state = DGG.DISABLED, image = image, image_pos = (0.0, 0.0, 0.059999999999999998), image_scale = 0.12, image_color = (0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.55000000000000004), sortOrder = 100, pos = (x, 0, -0.0))
             button.setTransparency(1)
             button.showQuantity = False
             button.greyOut = -1
             button.showRing = False
             button.skillStatus = False
             if locked:
                 lock = DirectFrame(parent = button, relief = None, image = self.lockArt, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, 0.035000000000000003))
                 button['state'] = DGG.NORMAL
                 button['command'] = base.localAvatar.guiMgr.showNonPayer
                 button['extraArgs'] = [
                     'Restricted_Radial_Menu',
                     5]
             
             self.tray[i + 1] = button
             x = x + 0.14999999999999999
             if i < self.numberOfItems - 1:
                 offset = offset + 0.01
                 self.skillTray.setX(self.skillTray.getX() - 0.074999999999999997)
             
         i < self.numberOfItems - 1
         if self.origMap[i][1] == True:
             skillId = self.traySkillMap[i]
             if linkedSkillIds.has_key(skillId):
                 skillId = linkedSkillIds[skillId]
             
             name = PLocalizer.InventoryTypeNames[skillId]
             hotkey = str(i + 1)
             totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId)
             timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(skillId)
             if not timeSpentRecharging:
                 timeSpentRecharging = 0
             
             if weaponMode not in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF, WeaponGlobals.DEFENSE_CANNON) and skillId in WeaponGlobals.SpecialSkills or WeaponGlobals.getSkillReputationCategoryId(skillId) not in (InventoryType.PistolRep, InventoryType.WandRep, InventoryType.CannonRep, InventoryType.GrenadeRep, InventoryType.DefenseCannonRep):
                 showRing = True
             else:
                 showRing = False
             locked = self.origMap[i][2]
             if weaponMode == WeaponGlobals.DEFENSE_CANNON:
                 button = AmmoSkillButton(skillId, i, self.callback, 99, 0, showQuantity = True, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked)
             else:
                 button = SkillButton(skillId, self.callback, 0, 0, showQuantity = False, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked)
             button.skillStatus = True
             if locked:
                 button.skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 button.skillButton['extraArgs'] = [
                     'Restricted_Radial_Menu',
                     5]
             
             if showRing:
                 button.skillRing.meterFaceHalf1.setScale(0.95999999999999996)
                 button.skillRing.meterFaceHalf2.setScale(0.95999999999999996)
             
             button.reparentTo(self.skillTray)
             button.setPos(x, 0, 0.070000000000000007)
             self.tray[i + 1] = button
             if weaponMode in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF):
                 lastAmmo = localAvatar.guiMgr.combatTray.lastAmmoSkillId.get(localAvatar.currentWeaponId)
                 if lastAmmo is not None:
                     if lastAmmo == skillId:
                         button.toggleButton(True)
                     
                 elif self.tray[1].skillStatus is True:
                     self.tray[1].toggleButton(True)
                 
             
             if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE):
                 inv = localAvatar.getInventory()
                 maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId)
                 if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId):
                     ammoAmt = WeaponGlobals.INF_QUANT
                 else:
                     ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                     ammoAmt = inv.getStackQuantity(ammoInvId)
                     ammoMax = inv.getStackLimit(ammoInvId)
                     button.showQuantity = True
                     button.updateQuantity(ammoAmt)
             
             x = x + 0.17000000000000001
             if i < self.numberOfItems - 1:
                 if weaponMode == WeaponGlobals.DEFENSE_CANNON:
                     self.skillTray.setX(self.skillTray.getX() - 0.072499999999999995)
                 else:
                     self.skillTray.setX(self.skillTray.getX() - 0.085000000000000006)
             
         i < self.numberOfItems - 1
     
     currentX = self.skillTray.getX()
     self.skillTray.setX(currentX + float(offset))
     if self.repMeter:
         self.repMeter.setPos(-currentX, 0.0, -0.11)
     
     self.updateSkillTrayStates()
     if weaponMode == WeaponGlobals.DEFENSE_CANNON:
         self.setMoveUpValue(0.34499999999999997)
     else:
         self.resetMoveUpVale()
     self.showSkillTray()