def selectPrev(self):
     if len(self.items) < 1:
         return None
     
     self.show()
     if len(self.items) > 1:
         keepTrying = True
     else:
         keepTrying = False
     while keepTrying:
         keepTrying = False
         self.choice = self.choice - 1
         if self.choice < 0 or self.choice > len(self.items) - 1:
             self.choice = len(self.items) - 1
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if self.items[self.choice]:
                 category = WeaponGlobals.getRepId(self.items[self.choice][0])
                 if not Freebooter.allowedFreebooterWeapon(category):
                     keepTrying = True
                 
             else:
                 keepTrying = True
         self.items[self.choice]
     self.cursor.setPos(self.ICON_WIDTH * self.choice + 0.080000000000000002, 0, 0.071999999999999995)
     taskMgr.remove('BarSelectHideTask' + str(self.getParent()))
     self.hideTask = taskMgr.doMethodLater(self.SelectionDelay, self.confirmSelection, 'BarSelectHideTask' + str(self.getParent()), extraArgs = [])
    def applyTo(self, trade, av):
        avId = av.getDoId()
        goldAmt = EnemyGlobals.getMaxGoldDrop(None, self.amount, 5)
        if Freebooter.getPaidStatusAI(avId):
            if REWARD_TO == 2 or REWARD_TO == 3:
                goldAmt *= GOLDFACTOR_HOLIDAY
            elif not Freebooter.getPaidStatusAI(avId):
                if REWARD_TO == 1 or REWARD_TO == 3:
                    goldAmt *= GOLDFACTOR_HOLIDAY

        trade.giveGoldInPocket(goldAmt)
 def loadWeaponButtons(self):
     for hotkey in self.hotkeys:
         hotkey.destroy()
     
     self.hotkeys = []
     for icon in self.icons:
         icon.destroy()
     
     self.icons = []
     for repMeter in self.repMeters:
         repMeter.destroy()
     
     self.repMeters = []
     self['frameSize'] = (0, self.ICON_WIDTH * len(self.items) + 0.040000000000000001, 0, self.HEIGHT)
     self.setX(-((self.ICON_WIDTH * len(self.items) + 0.040000000000000001) / 2.0))
     topGui = loader.loadModel('models/gui/toplevel_gui')
     kbButton = topGui.find('**/keyboard_button')
     for i in range(len(self.items)):
         if self.items[i]:
             category = WeaponGlobals.getRepId(self.items[i][0])
             icon = DirectFrame(parent = self, state = DGG.DISABLED, relief = None, frameSize = (0, 0.080000000000000002, 0, 0.080000000000000002), pos = (self.ICON_WIDTH * i + 0.080000000000000002, 0, 0.082000000000000003))
             icon.setTransparency(1)
             hotkeyText = 'F%s' % self.items[i][1]
             hotkey = DirectFrame(parent = icon, state = DGG.DISABLED, relief = None, text = hotkeyText, text_align = TextNode.ACenter, text_scale = 0.044999999999999998, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, image = kbButton, image_scale = 0.059999999999999998, image_pos = (0, 0, 0.01), image_color = (0.5, 0.5, 0.34999999999999998, 1), pos = (0, 0, 0.080000000000000002))
             self.hotkeys.append(hotkey)
             category = WeaponGlobals.getRepId(self.items[i][0])
             if Freebooter.getPaidStatus(base.localAvatar.getDoId()) or Freebooter.allowedFreebooterWeapon(category):
                 asset = ItemGlobals.getIcon(self.items[i][0])
                 if asset:
                     texCard = self.card.find('**/%s' % asset)
                     icon['geom'] = texCard
                     icon['geom_scale'] = 0.080000000000000002
                 
                 icon.resetFrameSize()
                 self.icons.append(icon)
             else:
                 texCard = topGui.find('**/pir_t_gui_gen_key_subscriber*')
                 icon['geom'] = texCard
                 icon['geom_scale'] = 0.20000000000000001
                 icon.resetFrameSize()
                 self.icons.append(icon)
             repMeter = DirectWaitBar(parent = icon, relief = DGG.SUNKEN, state = DGG.DISABLED, borderWidth = (0.002, 0.002), range = 0, value = 0, frameColor = (0.23999999999999999, 0.23999999999999999, 0.20999999999999999, 1), barColor = (0.80000000000000004, 0.80000000000000004, 0.69999999999999996, 1), pos = (-0.050000000000000003, 0, -0.052499999999999998), hpr = (0, 0, 0), frameSize = (0.0050000000000000001, 0.095000000000000001, 0, 0.012500000000000001))
             self.repMeters.append(repMeter)
             inv = base.localAvatar.getInventory()
             if inv:
                 repValue = inv.getReputation(category)
                 (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(category, repValue)
                 max = ReputationGlobals.getReputationNeededToLevel(category, level)
                 repMeter['range'] = max
                 repMeter['value'] = leftoverValue
    def applyTo(self, trade, av):
        avId = av.getDoId()
        rewardAmount = self.amount
        if Freebooter.getPaidStatusAI(avId):
            if REWARD_TO == 2 or REWARD_TO == 3:
                rewardAmount = self.amount * REPFACTOR_HOLIDAY
            elif not Freebooter.getPaidStatusAI(avId):
                if REWARD_TO == 1 or REWARD_TO == 3:
                    rewardAmount = self.amount * REPFACTOR_HOLIDAY

        if av.getTempDoubleXPReward():
            rewardAmount = rewardAmount * 2

        trade.giveReputation(InventoryType.GeneralRep, rewardAmount)
        trade.giveReputation(InventoryType.OverallRep, rewardAmount)
 def handleCommitPurchase(self):
     if self.purchaseInventory == [] and self.sellInventory == []:
         base.localAvatar.guiMgr.createWarning(PLocalizer.EmptyPurchaseWarning, PiratesGuiGlobals.TextFG6)
         return None
     
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if self.purchaseInventory[0][0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][0] != ItemId.MERCHANT_L1:
             base.localAvatar.guiMgr.showNonPayer('Purchase_Restriction', 3)
             return None
         
     
     inventory = base.localAvatar.getInventory()
     if inventory:
         if inventory.getGoldInPocket() < self.balance:
             base.localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughMoneyWarning, PiratesGuiGlobals.TextFG6)
             return None
         
         if self.balance < 0 and inventory.getGoldInPocket() + self.balance > InventoryGlobals.GOLD_CAP:
             base.localAvatar.guiMgr.createWarning(PLocalizer.CannotHoldGoldWarning, PiratesGuiGlobals.TextFG6)
             return None
         
         if len(inventory.getShipDoIdList()) >= inventory.getCategoryLimit(InventoryCategory.SHIPS):
             base.localAvatar.guiMgr.createWarning(PLocalizer.CannotHoldShipWarning, PiratesGuiGlobals.TextFG6)
             return None
         
     
     nameData = [
         PLocalizer.PirateShipPrefix.keys(),
         PLocalizer.PirateShipSuffix.keys()]
     self.namePanel = NamePanelGui.NamePanelGui(PLocalizer.NamePanelTitle, nameData)
     self.namePanel.setPos(0.20000000000000001, 0, 0)
     self.lockStore()
     self.acceptOnce('returnStore', self.unlockStore)
     self.acceptOnce('nameChosen', self.handleCommitPurchasePart2)
 def onAmmoClick(self, skillId):
     button = self.buttons[skillId]
     if button.isLocked():
         if not Freebooter.getPaidStatus(base.localAvatar.doId) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
             localAvatar.guiMgr.showNonPayer()
         
         return None
     
     if button.canPurchase(self._bankNotes):
         if self.addAmmoSkill(skillId):
             self._bankNotes -= button.cost
             self.updateBankNoteText()
             button.disablePurchase()
             if self.sfxAmmoBought:
                 base.playSfx(self.sfxAmmoBought)
             
         elif not self.hasSkill(skillId):
             button.flash()
             self.msgMgr.showNoAmmoSlot()
             if self.sfxAmmoDeny:
                 base.playSfx(self.sfxAmmoDeny)
             
         
     elif not self.hasSkill(skillId):
         button.flash()
         self.msgMgr.showNotEnoughBankNotes()
         if self.sfxAmmoDeny:
             base.playSfx(self.sfxAmmoDeny)
         
     
     if self.hasSkill(skillId):
         base.localAvatar.guiMgr.combatTray.skillTray.updateSkillTray(InventoryType.DefenseCannonRep, WeaponGlobals.DEFENSE_CANNON, hideFirst = False)
         base.localAvatar.guiMgr.combatTray.triggerSkillTraySkill(skillId)
         self.cannon.cgui.showCannonControls()
         self.updateQuantities()
    def checkLevel(self, repId, minLvl):
        inv = localAvatar.getInventory()
        if inv:
            repAmt = inv.getAccumulator(repId)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                (item, quantity) = self.data
                if item != ItemId.INTERCEPTOR_L1 and item != ItemId.MERCHANT_L1:
                    if not self.miscText:
                        self.miscText = DirectLabel(parent = self, relief = None, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, text_pos = (0.050000000000000003, 0, 0), pos = (0.16, 0, 0.025000000000000001))

                    self['image_color'] = Vec4(1, 0.5, 0.5, 1)
                    self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
                    self.miscText['text'] = PLocalizer.noFreebooterCap
                    subCard = loader.loadModel('models/gui/toplevel_gui')
                    appendMe = DirectFrame(parent = self, relief = None, pos = (self.width - 0.40500000000000003, 0, -0.014999999999999999), state = DGG.DISABLED, geom = subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale = 0.12, geom_pos = (0.059999999999999998, 0, 0.059999999999999998))
                    subCard.removeNode()

            elif minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]:
                if not self.miscText:
                    self.miscText = DirectLabel(parent = self, relief = None, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.16, 0, 0.025000000000000001))

                self['image_color'] = Vec4(1, 0.5, 0.25, 1)
                self['state'] = DGG.DISABLED
                self.miscText['text_fg'] = PiratesGuiGlobals.TextFG8
                self.miscText['text'] = PLocalizer.LevelRequirement % minLvl
 def __init__(self, callback, skillId, skillRank):
     if not AmmoPanelButton.SkillIcons:
         AmmoPanelButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
         AmmoPanelButton.Image = (AmmoPanelButton.SkillIcons.find('**/base'), AmmoPanelButton.SkillIcons.find('**/base_down'), AmmoPanelButton.SkillIcons.find('**/base_over'))
     
     self.locked = True
     self.purchaseable = True
     self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId)
     self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
     if self.amount == -1:
         self.amount = PLocalizer.Unlimited
     
     self.skillId = skillId
     self.skillRank = skillRank
     self.infoBox = None
     self.flashIval = None
     asset = RadialMenu.getSkillIconName(skillId, 0)
     geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset)
     self.geom = geom
     if self.locked:
         asset = None
         geom = None
     
     DirectButton.__init__(self, relief = None, pos = (0, 0, 0), text = '?', text_scale = 0.10000000000000001, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_pos = (0.0050000000000000001, -0.035000000000000003), text_align = TextNode.ACenter, image = AmmoPanelButton.Image, image_scale = 0.12, geom = geom, geom_scale = 0.12, command = callback, textMayChange = 1, sortOrder = 70, extraArgs = [
         skillId])
     self.initialiseoptions(AmmoPanelButton)
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
     if not Freebooter.getPaidStatus(base.localAvatar.doId) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
         self.lock = DirectFrame(parent = self, relief = None, image = self.lockIcon, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, -0.025000000000000001), sortOrder = 99)
     
     self.bind(DGG.ENTER, self.showDetails)
     self.bind(DGG.EXIT, self.hideDetails)
Esempio n. 9
0
    def requestInteraction(self, avId, interactType=0):
        if self.buildingUid == LocationIds.KINGSHEAD_OUTER_DOOR and not Freebooter.getPaidStatus(localAvatar.getDoId()):
            localAvatar.guiMgr.showNonPayer(quest="Restricted_Location", focus=0)
            return None

        print "requestinteraction", 0
        if avId == localAvatar.doId:
            self.fadeOut()
            return None

        if self.questNeeded:
            questHistory = localAvatar.getQuestLadderHistory()
            currentQuests = localAvatar.getQuests()
            container = QuestLadderDB.getContainer(self.questNeeded)
            canEnter = False
            for quest in currentQuests:
                if container.getQuestId() == quest.getQuestId() or container.hasQuest(quest.getQuestId()):
                    canEnter = True
                    continue

            if not canEnter:
                if self.buildingUid == LocationIds.UNDEAD_POKER_SHACK:
                    localAvatar.guiMgr.createWarning(PLocalizer.ClubheartsQuestWarning, PiratesGuiGlobals.TextFG6)

                return None

        print "requestinteraction", 2
        DistributedInteractive.DistributedInteractive.requestInteraction(self, avId, interactType)
Esempio n. 10
0
 def enableStatsOV(self, shipOV):
     self.snapShot = ShipSnapshot(self, shipOV, self['siegeTeam'], pos = self['snapShotPos'])
     typeStr = ''
     if self['siegeTeam']:
         hp = shipOV.maxHp
         sp = shipOV.maxSp
     else:
         hp = shipOV.Hp
         sp = shipOV.Sp
     if hp <= 0:
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.DeployShip
         stateStr = '\x01Ired\x01%s\x02' % PLocalizer.ShipSunk
         self['shipColorScale'] = VBase4(1, 0.40000000000000002, 0.40000000000000002, 1)
         self.button['image3_color'] = VBase4(*PiratesGuiGlobals.ButtonColor3[2])
         self.button['geom3_color'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 0.40000000000000002)
         self.button['text3_color'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 0.40000000000000002)
         self.button['helpText'] = PLocalizer.ShipSunk
     elif len(shipOV.crew) >= shipOV.maxCrew:
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.BoardShip
         self.button['helpText'] = PLocalizer.ShipFull
         stateStr = '\x01red\x01%s\x02' % (PLocalizer.ShipFull,)
         self['shipColorScale'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1)
     elif localAvatar.getActiveShipId() and shipOV.doId != localAvatar.getActiveShipId():
         self.button['state'] = DGG.DISABLED
         self.button['text'] = PLocalizer.DeployShip
         self.button['helpText'] = PLocalizer.OtherShipOut
         stateStr = '\x01Ired\x01%s\x02' % PLocalizer.OtherShipOut
         self['shipColorScale'] = VBase4(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1)
     elif shipOV.state in 'Off':
         self.button['state'] = DGG.NORMAL
         self.button['text'] = PLocalizer.DeployShip
         stateStr = PLocalizer.ShipInBottle
         self.button['helpText'] = PLocalizer.ShipInBottle
     else:
         self.button['state'] = DGG.NORMAL
         self.button['text'] = PLocalizer.BoardShip
         stateStr = PLocalizer.ShipAtSea
         self.button['helpText'] = PLocalizer.ShipAtSea
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
         self.button['command'] = base.localAvatar.guiMgr.showNonPayer
         self.button['extraArgs'] = [
             'Restricted_ShipFrame_Deploy',
             3]
         self.button['text'] = PLocalizer.Locked
         subgui = loader.loadModel('models/gui/toplevel_gui')
         if subgui:
             self.button['geom'] = subgui.find('**/pir_t_gui_gen_key_subscriber')
             self.button['geom_scale'] = 0.14999999999999999
             self.button['geom_color'] = Vec4(0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1.0)
             subgui.removeNode()
         
     
     if typeStr:
         self.typeLabel['text'] = '\x01smallCaps\x01(%s)\x02' % typeStr
Esempio n. 11
0
 def giveReputation(self, category, amount):
     if self.avatarId:
         av = self.air.doId2do.get(self.avatarId)
         if av:
             inv = av.getInventory()
             avExpMult = av.getExpMult()
             amount = int(avExpMult * amount)
             if inv:
                 if category == InventoryType.OverallRep:
                     curLevel = av.getLevel()
                     if Freebooter.getPaidStatusAI(self.avatarId):
                         levelCap = ReputationGlobals.GlobalLevelCap
                     else:
                         levelCap = Freebooter.FreeOverallLevelCap
                     if amount > 0 and curLevel < levelCap:
                         curRepTotal = inv.getAccumulator(InventoryType.OverallRep)
                         (newLevel, left) = ReputationGlobals.getLevelFromTotalReputation(InventoryType.OverallRep, curRepTotal + amount)
                         if newLevel >= levelCap:
                             amount = max(0, amount - left)
                         
                         self.giveAccumulatorAddition(category, amount)
                     
                 elif category == InventoryType.GeneralRep:
                     self.giveAccumulatorAddition(category, amount)
                 elif Freebooter.getPaidStatusAI(self.avatarId):
                     if category in [
                         InventoryType.PotionsRep,
                         InventoryType.FishingRep]:
                         levelCap = ReputationGlobals.MinigameLevelCap
                     else:
                         levelCap = ReputationGlobals.LevelCap
                 else:
                     levelCap = Freebooter.FreeLevelCap
                 repAmt = inv.getAccumulator(category)
                 (curLevel, curLeft) = ReputationGlobals.getLevelFromTotalReputation(category, repAmt)
                 if curLevel >= levelCap:
                     amount = 0
                 
                 (expLevel, left) = ReputationGlobals.getLevelFromTotalReputation(category, repAmt + amount)
                 if expLevel >= levelCap and curLevel < levelCap:
                     amount = max(0, amount - left)
                 
                 self.giveAccumulatorAddition(category, amount)
    def getItemRequirements(self, itemType, otherAdds = []):
        if not itemType:
            return None

        results = { }
        if game.process == 'client':
            paidStatus = Freebooter.getPaidStatus(self.ownerId)
        else:
            paidStatus = Freebooter.getPaidStatusAI(self.ownerId)
        rarity = ItemGlobals.getRarity(itemType)
        if rarity != ItemConstants.CRUDE and not paidStatus:
            results['paidStatus'] = (rarity != ItemConstants.CRUDE, False)

        itemClass = ItemGlobals.getClass(itemType)
        if itemClass == InventoryType.ItemTypeWeapon or itemClass == InventoryType.ItemTypeCharm:
            itemRepId = ItemGlobals.getItemRepId(itemType)
            itemRep = self.getReputation(itemRepId)
            itemLevel = ReputationGlobals.getLevelFromTotalReputation(itemRepId, itemRep)[0]
            weaponReq = ItemGlobals.getWeaponRequirement(itemType)
            trainingToken = EconomyGlobals.getItemTrainingReq(itemType)
            trainingAmt = self.getItemQuantity(trainingToken)
            for currAdd in otherAdds:
                otherAdd = InvItem(currAdd)
                if otherAdd.getCat() == trainingToken and otherAdd.getCount() > 0:
                    trainingAmt += otherAdd.getCount()
                    continue

            if not weaponReq == None:
                pass
            weaponLevelPass = itemLevel >= weaponReq
            if not trainingToken == 0 and trainingToken == None:
                pass
            weaponTrainPass = trainingAmt > 0
            if weaponLevelPass:
                pass
            results['itemLevel'] = (weaponReq, weaponTrainPass)
        else:
            results['itemLevel'] = (0, True)
        return results
Esempio n. 13
0
 def checkFreebooter(self, itemId, avId):
     if ItemGlobals.getRarity(itemId) == ItemGlobals.CRUDE:
         return None
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             return None
         
     if itemId in [
         InventoryType.RegularLure]:
         return None
     
     if not Freebooter.getPaidStatus(avId):
         self.highlightRed(PLocalizer.FreebooterDisallow)
 def addAmmoSkill(self, skillId):
     index = -1
     for i in range(len(PiratesGlobals.CANNON_DEFENSE_SKILLS)):
         if PiratesGlobals.CANNON_DEFENSE_SKILLS[i] == InventoryType.DefenseCannonEmpty:
             index = i
             break
             continue
     
     if (index < 0 or not Freebooter.getPaidStatus(base.localAvatar.doId)) and index >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
         return False
     
     PiratesGlobals.CANNON_DEFENSE_SKILLS.remove(InventoryType.DefenseCannonEmpty)
     PiratesGlobals.CANNON_DEFENSE_SKILLS.insert(index, skillId)
     self.ammoQuantities[skillId] = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
     return True
 def __init__(self, skillId, slotId, callback, quantity = 0, skillRank = 0, showQuantity = False, showHelp = False, showRing = False, hotkey = None, name = '', showIcon = True, showLock = False, rechargeSkillId = False, assocAmmo = []):
     if skillId in [
         InventoryType.DefenseCannonRoundShot,
         InventoryType.DefenseCannonEmpty]:
         showQuantity = False
     
     if not Freebooter.getPaidStatus(base.localAvatar.doId) and slotId >= CannonDefenseGlobals.FREEBOOTER_MAX_AMMO_SLOTS:
         showLock = True
     
     SkillButton.SkillButton.__init__(self, skillId, callback, quantity, skillRank, showQuantity, showHelp, showRing, hotkey, name, showIcon, showLock, rechargeSkillId, assocAmmo)
     self.toggleFrame['image_scale'] = 0.55000000000000004
     self.toolTipBox = None
     self.slotId = slotId
     self._initButtons()
     self.updateSkillId(skillId)
 def updateProfile(self):
     imageName = self.ShipIconTable.get(self.purchaseInventory[0][0])
     myTexCard = self.card.find('**/' + imageName + '*')
     myTex = myTexCard.findAllTextures()[0]
     self.purchaseTitle['text'] = PLocalizer.InventoryTypeNames[self.purchaseInventory[0][0]]
     self.descText['text'] = (PLocalizer.ShipDescriptions[self.purchaseInventory[0][0]],)
     self.shipImage['image'] = myTex
     self.shipImage['image_scale'] = 0.25
     self.updateStats()
     self.shipStats.refreshBars(self.statData)
     self.updateBalance()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if self.purchaseInventory[0][0] != ItemId.INTERCEPTOR_L1 and self.purchaseInventory[0][0] != ItemId.MERCHANT_L1:
             self.lock.show()
         else:
             self.lock.hide()
Esempio n. 17
0
 def addOwnShip(self, shipId, callback):
     shipOV = base.cr.getOwnerView(shipId)
     if (not shipOV or self._siegeTeam) and localAvatar.getSiegeTeam() and localAvatar.getSiegeTeam() != self._siegeTeam:
         return None
     
     shipFrame = self.getFrame(shipId)
     if not shipFrame:
         mastInfo = ShipGlobals.getMastSetup(shipOV.shipClass)
         shipFrame = ShipFrameDeploy(parent = None, shipId = shipId, shipName = shipOV.name, shipClass = shipOV.shipClass, mastInfo = mastInfo, shipType = ShipFrameDeploy.STOwn, siegeTeam = self._siegeTeam, command = callback, extraArgs = [
             shipId])
         shipFrame.enableStatsOV(shipOV)
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
             shipFrame.nameLabel['text'] = PLocalizer.noFreebooterCap
             shipFrame.nameLabel['text_fg'] = (1, 0.69999999999999996, 0.69999999999999996, 1)
         
     
     self.addFrameOwn(shipFrame)
 def changeAmmo(self, amt = 1):
     if amt == 0:
         return None
     
     keepChanging = True
     ammoSkillId = self.getAmmoSkillId()
     while keepChanging:
         ammoSkillId += amt
         if ammoSkillId > InventoryType.CannonGrappleHook:
             ammoSkillId = InventoryType.CannonRoundShot
         
         if ammoSkillId < InventoryType.begin_WeaponSkillCannon + 1:
             ammoSkillId = InventoryType.CannonGrappleHook
         
         inv = base.localAvatar.getInventory()
         if ammoSkillId > InventoryType.CannonBullet:
             keepChanging = False
         
         if inv and inv.getStackQuantity(ammoSkillId) >= 2:
             keepChanging = False
         
         if WeaponGlobals.isInfiniteAmmo(ammoSkillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), ammoSkillId):
             keepChanging = False
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(ammoSkillId):
                 keepChanging = True
             
         WeaponGlobals.canFreeUse(ammoSkillId)
     self.setAmmoSkillId(ammoSkillId)
     del ammoSkillId
     if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()):
         self.cgui.setAmmoLeft(-1, -1)
     elif inv:
         ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId())
         self.numShots = inv.getStackQuantity(ammoInvId)
         maxShots = inv.getStackLimit(ammoInvId)
         self.cgui.setAmmoLeft(self.numShots, maxShots)
     
     self.cgui.setAmmoId(self.getAmmoSkillId())
     self.updateCannonDressing()
     self.hideCannonDressing()
     self.setVolley(0)
Esempio n. 19
0
 def canLocalUseItem(self, itemTuple):
     canUse = 1
     reason = ItemConstants.REASON_NONE
     itemCat = itemTuple[0]
     itemId = itemTuple[1]
     rarity = ItemGlobals.getRarity(itemId)
     if rarity != ItemConstants.CRUDE and not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         canUse = 0
         reason = ItemConstants.REASON_VELVETROPE
         return (canUse, reason)
     elif itemCat == InventoryType.ItemTypeClothing:
         gender = localAvatar.style.getGender()
         if gender == 'm' and ItemGlobals.getMaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
         elif gender == 'f' and ItemGlobals.getFemaleModelId(itemId) == -1:
             canUse = 0
             reason = ItemConstants.REASON_GENDER
             return (canUse, reason)
         
     elif itemCat in [
         InventoryType.ItemTypeWeapon,
         InventoryType.ItemTypeCharm]:
         inv = localAvatar.getInventory()
         if not inv:
             canUse = 0
             reason = ItemConstants.REASON_INVENTORY
             return (canUse, reason)
         
         reqs = localAvatar.getInventory().getItemRequirements(itemId)
         if reqs == None or filter(lambda x: reqs[x][1] == False, reqs):
             canUse = 0
             reason = ItemConstants.REASON_LEVEL
             return (canUse, reason)
         
     
     return (canUse, reason)
Esempio n. 20
0
 def _QuestTitleList__makeButtons(self, guiParent, tree):
     i = 0
     for (node, indent) in self._QuestTitleList__graphWalker(tree):
         if not node.questId:
             continue
         
         if node.hideButton:
             continue
         
         isContainer = isinstance(node.questDNA, QuestLadderDNA.QuestContainerDNA)
         text = self._QuestTitleList__getText(indent, node.questId, isContainer)
         text_scale = PiratesGuiGlobals.TextScaleLarge
         frameSize = (0, 0.92000000000000004, 0, 0.042000000000000003)
         text_pos = (0.059999999999999998, 0.01)
         textFg = PiratesGuiGlobals.TextFG1
         if indent == 0:
             text_pos = (0.01, 0.01)
         
         button = DirectButton(parent = guiParent, relief = None, frameSize = frameSize, borderWidth = (0.0050000000000000001, 0.0050000000000000001), text = text, text_fg = textFg, text_scale = text_scale, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, text_pos = text_pos, command = self.select, extraArgs = [
             node.questId])
         questDNA = QuestDB.QuestDict.get(node.questId)
         if questDNA:
             if questDNA.getVelvetRoped():
                 if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                     subCard = loader.loadModel('models/gui/toplevel_gui')
                     appendMe = DirectFrame(parent = button, relief = None, pos = (self.width - 0.97999999999999998, 0, -0.029999999999999999), state = DGG.DISABLED, geom = subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale = 0.10000000000000001, geom_pos = (0.059999999999999998, 0, 0.059999999999999998))
                     subCard.removeNode()
                 
             
         
         button.accept('press-wheel_up-%s' % button.guiId, self.mouseWheelUp)
         button.accept('press-wheel_down-%s' % button.guiId, self.mouseWheelDown)
         button.indent = indent
         button.questId = node.questId
         self.updateButton(button)
         self.buttons.append(button)
         i += 1
    def getCargoResults(self):
        missionTime, shipDamage, skeletonKills, navyKills, creatureKills, seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost, exp, gold, cargo, numCrew = self.stats
        pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills, pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills, pRepairCost, pExp, pGold, pCargo, pLootBoxes, dummyCrew = self.playerStats
        inventory = base.localAvatar.getInventory()
        if inventory:
            currentGold = inventory.getGoldInPocket()
        avId = base.localAvatar.getDoId()
        cargoValue = EconomyGlobals.getCargoTotalValue(pCargo)
        totalGold = cargoValue + pGold
        bonusGold = 0
        if base.localAvatar.ship:
            if base.localAvatar.ship.getOwnerId() == avId:
                if len(base.localAvatar.ship.getCrew()) > 1:
                    bonusGold = int(totalGold *
                                    EconomyGlobals.CAPTAIN_LOOT_MULTIPLIER)
                    totalGold += bonusGold
            if base.cr.newsManager and (base.cr.newsManager.getHoliday(
                    HolidayGlobals.DOUBLEGOLDHOLIDAYPAID)
                                        and Freebooter.getPaidStatus(avId)
                                        or base.cr.newsManager.getHoliday(
                                            HolidayGlobals.DOUBLEGOLDHOLIDAY)):
                totalGold *= 2
            netGold = totalGold - pRepairCost
            self.results = []
            self.results.append({
                'Type': 'Title',
                'Text': PLocalizer.CargoPlunder,
                'Value1': ''
            })
            if pGold:
                self.results.append({
                    'Type': 'Entry',
                    'Text': PLocalizer.GoldLooted,
                    'Value1': pGold,
                    'Value2': gold
                })
            len(pCargo) == 0 and self.results.append({
                'Type': 'Entry',
                'Text': PLocalizer.NoCargoLooted,
                'Value1': '',
                'UnwrapMode': 1
            })
        else:
            cargoDict = {}
            for itemId in pCargo:
                cargoCount = cargoDict.get(itemId, None)
                if cargoCount == None:
                    cargoDict[itemId] = 0
                cargoDict[itemId] += 1

            for cargoKey in cargoDict:
                amount = cargoDict[cargoKey]
                self.results.append({
                    'Type': 'Cargo',
                    'Text': '',
                    'Value1': cargoKey,
                    'UnwrapMode': 1,
                    'Amount': amount
                })

            if bonusGold > 0:
                self.results.append({
                    'Type': 'Space',
                    'Text': '',
                    'Value1': '',
                    'UnwrapMode': 1
                })
                self.results.append({
                    'Type':
                    'Entry',
                    'Text':
                    PLocalizer.CaptainsBonus,
                    'Value1':
                    str(bonusGold) + ' ' + PLocalizer.MoneyName,
                    'UnwrapMode':
                    1
                })
        if base.cr.newsManager and (base.cr.newsManager.getHoliday(
                HolidayGlobals.DOUBLEGOLDHOLIDAYPAID)
                                    and Freebooter.getPaidStatus(avId)
                                    or base.cr.newsManager.getHoliday(
                                        HolidayGlobals.DOUBLEGOLDHOLIDAY)):
            self.results.append({
                'Type': 'Space',
                'Text': '',
                'Value1': '',
                'UnwrapMode': 1
            })
            self.results.append({
                'Type':
                'Entry',
                'Text':
                PLocalizer.DoubleGoldBonus,
                'Value1':
                str(totalGold / 2) + ' ' + PLocalizer.MoneyName,
                'UnwrapMode':
                1
            })
        self.results.append({
            'Type': 'Space',
            'Text': '',
            'Value1': '',
            'UnwrapMode': 1
        })
        self.results.append({
            'Type': 'Title',
            'Text': PLocalizer.PlunderShare,
            'Value1': str(netGold) + ' ' + PLocalizer.MoneyName,
            'UnwrapMode': 1
        })
        return self.results
Esempio n. 22
0
    def showLoot(self,
                 plunder=[],
                 gold=0,
                 collect=0,
                 card=0,
                 cloth=0,
                 color=0,
                 jewel=None,
                 tattoo=None,
                 weapon=None,
                 bounty=0):
        for loot in self.loot:
            loot.destroy()
            del loot

        self.loot = []
        gender = localAvatar.style.getGender()
        self.show()
        self.setAlphaScale(1.0)
        treasure = []
        for itemId in self.icons.iterkeys():
            count = 0
            for item in plunder:
                if item == itemId:
                    count += 1
                    continue

            if count > 0:
                treasure.append([itemId, count])
                continue

        plunder = treasure
        if gold:
            plunder.append([ItemId.GOLD, gold])
            LootPopupPanel.lootSfx.play()

        if bounty:
            plunder.append([ItemId.BOUNTY, bounty])
            LootPopupPanel.lootSfx.play()

        if collect:
            plunder.append([ItemId.COLLECT, collect])
            LootPopupPanel.lootSfx.play()

        if card:
            plunder.append([ItemId.CARD, card])
            LootPopupPanel.lootSfx.play()

        if cloth:
            plunder.append([ItemId.CLOTHING, (cloth, color)])
            LootPopupPanel.lootSfx.play()

        if jewel is not None:
            plunder.append([ItemId.QUEST_DROP_JEWEL, jewel])
            LootPopupPanel.lootSfx.play()

        if tattoo is not None:
            plunder.append([ItemId.QUEST_DROP_TATTOO, tattoo])
            LootPopupPanel.lootSfx.play()

        if weapon is not None:
            plunder.append([ItemId.QUEST_DROP_WEAPON, weapon])
            LootPopupPanel.lootSfx.play()

        for item in plunder:
            (itemType, quantity) = item
            if itemType == ItemId.COLLECT:
                itemId = quantity
                howRare = CollectionMap.Collection_Rarity.get(itemId, 0)
                rarityText = PLocalizer.CollectionRarities.get(howRare)
                value = CollectionValues.get(howRare, 0)
                itemName = PLocalizer.Collections[itemId]
                howManyDoIHave = localAvatar.getInventory().getStackQuantity(
                    itemId)
                howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1)
                if howManyDoIHave < howManyINeed:
                    textInfo = PLocalizer.CollectionPopupNewText % (
                        itemName, rarityText, value)
                else:
                    textInfo = PLocalizer.CollectionPopupDuplicateText % (
                        itemName, rarityText, value)
                pic_name = CollectionMap.Assets[itemId]
                lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name)
                iconScale = 0.34999999999999998
            elif itemType == ItemId.CLOTHING:
                (clothingId, colorId) = quantity
                if clothingId in ClothingGlobals.quest_items:
                    textInfo = PLocalizer.getItemName(clothingId)
                else:
                    textInfo = PLocalizer.TailorColorStrings.get(colorId)
                    textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(
                        ItemGlobals.getType(clothingId))
                clothingType = ItemGlobals.getType(clothingId)
                iconScale = 0.13
                if clothingType == 0:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_hat')
                elif clothingType == 1:
                    lootIcon = loader.loadModel('models/gui/char_gui').find(
                        '**/chargui_cloth')
                    iconScale = 0.29999999999999999
                elif clothingType == 2:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_vest')
                elif clothingType == 3:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_coat')
                elif clothingType == 4:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_pants')
                elif clothingType == 5:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_belt')
                elif clothingType == 6:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_sock')
                else:
                    lootIcon = LootPopupPanel.TailorGui.find(
                        '**/icon_shop_tailor_booths')
            elif itemType == ItemId.CARD:
                textInfo = PLocalizer.InventoryTypeNames.get(quantity)
                pic_name = ''
                lootIcon = PlayingCardGlobals.getImage(
                    'standard', PlayingCardGlobals.getSuit(quantity),
                    PlayingCardGlobals.getRank(quantity))
                iconScale = 0.20000000000000001
            elif itemType == ItemId.GOLD:
                textInfo = PLocalizer.LootGold % str(quantity)
                potionPercent = PotionGlobals.getGoldBoostEffectPercent(
                    localAvatar)
                potionGold = 0
                textInfo = PLocalizer.LootGold % str(quantity)
                if base.cr.newsManager:
                    if base.cr.newsManager.getHoliday(
                            HolidayGlobals.DOUBLEGOLDHOLIDAYPAID
                    ) or Freebooter.getPaidStatus(base.localAvatar.getDoId(
                    )) or base.cr.newsManager.getHoliday(
                            HolidayGlobals.DOUBLEGOLDHOLIDAY):
                        textInfo = PLocalizer.LootGold % str(
                            quantity /
                            2) + '\n + ' + PLocalizer.LootGoldDouble % str(
                                quantity / 2)

                if potionGold > 0:
                    textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(
                        potionGold)

                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.27000000000000002
            elif itemType == ItemId.BOUNTY:
                textInfo = PLocalizer.LootBounty % str(quantity)
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.27000000000000002
            elif itemType == ItemId.CARGO_CRATE:
                if quantity == 1:
                    textInfo = PLocalizer.CargoCrate % quantity
                else:
                    textInfo = PLocalizer.CargoCrateP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_CHEST:
                if quantity == 1:
                    textInfo = PLocalizer.CargoChest % quantity
                else:
                    textInfo = PLocalizer.CargoChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.CargoSkChest % quantity
                else:
                    textInfo = PLocalizer.CargoSkChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTSAC:
                if quantity == 1:
                    textInfo = PLocalizer.LootSac % quantity
                else:
                    textInfo = PLocalizer.LootSacP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootChest % quantity
                else:
                    textInfo = PLocalizer.LootChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_LOOTSKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootSkChest % quantity
                else:
                    textInfo = PLocalizer.LootSkChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SHIPUPGRADECHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootUpgradeChest % quantity
                else:
                    textInfo = PLocalizer.LootUpgradeChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.CARGO_SHIPUPGRADESKCHEST:
                if quantity == 1:
                    textInfo = PLocalizer.LootRareUpgradeChest % quantity
                else:
                    textInfo = PLocalizer.LootRareUpgradeChestP % quantity
                lootIcon = self.icons.get(itemType)[0]
                iconScale = 0.089999999999999997
            elif itemType == ItemId.QUEST_DROP_JEWEL:
                textInfo = None
                type = None
                lootIcon = None
                iconScale = 1.0
                type = ItemGlobals.getType(quantity)
                textInfo = PLocalizer.getItemName(quantity)
                if type == ItemGlobals.BROW:
                    lootIcon = LootPopupPanel.JewelerIconsB.find(
                        '**/icon_shop_tailor_brow')
                    iconScale = (-0.14000000000000001, 0.14000000000000001,
                                 0.14000000000000001)
                elif type == ItemGlobals.EAR:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_ears')
                    iconScale = (-0.34999999999999998, 0.34999999999999998,
                                 0.34999999999999998)
                elif type == ItemGlobals.NOSE:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_nose')
                    iconScale = (0.34999999999999998, 0.34999999999999998,
                                 0.34999999999999998)
                elif type == ItemGlobals.MOUTH:
                    lootIcon = LootPopupPanel.JewelerIconsA.find(
                        '**/chargui_mouth')
                    iconScale = (0.32500000000000001, 0.32500000000000001,
                                 0.32500000000000001)
                elif type == ItemGlobals.HAND:
                    lootIcon = LootPopupPanel.JewelerIconsB.find(
                        '**/icon_shop_tailor_hand')
                    iconScale = (0.125, 0.125, 0.125)
                else:
                    lootIcon = None
            elif itemType == ItemId.QUEST_DROP_TATTOO:
                textInfo = None
                type = None
                lootIcon = None
                iconScale = 1.0
                type = ItemGlobals.getType(quantity)
                textInfo = PLocalizer.getItemName(quantity)
                if type == ItemGlobals.CHEST:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_chest_male')
                    iconScale = 0.10000000000000001
                elif type == ItemGlobals.ARM:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_arm')
                    iconScale = 0.10000000000000001
                elif type == ItemGlobals.FACE:
                    lootIcon = LootPopupPanel.TattooIcons.find(
                        '**/icon_shop_tailor_face_male')
                    iconScale = 0.10000000000000001
                else:
                    lootIcon = None
            elif itemType == ItemId.QUEST_DROP_WEAPON:
                weaponId = quantity
                iconScale = 0.10000000000000001
                textInfo = None
                lootIcon = None
                iconName = getItemIcons(weaponId)
                if iconName is not None:
                    lootIcon = LootPopupPanel.WeaponIcons.find('**/' +
                                                               iconName)
                    textInfo = PLocalizer.InventoryTypeNames.get(weaponId)

            entry = DirectFrame(parent=self,
                                relief=None,
                                geom=lootIcon,
                                geom_scale=iconScale,
                                text=textInfo,
                                text_scale=PiratesGuiGlobals.TextScaleSmall,
                                text_align=TextNode.ALeft,
                                text_fg=PiratesGuiGlobals.TextFG0,
                                text_pos=(0.070000000000000007, 0.01),
                                text_font=PiratesGlobals.getInterfaceFont())
            entry.setTransparency(1)
            self.loot.append(entry)

        self.repackPanels()
    def updateList(self):
        self.recipeList.removeAndDestroyAllItems()
        self.buttons = []
        self.inactiveButtons = []
        playerLevel = self.potionGame.dist.getPlayerPotionLevel()
        notNew_list = self.potionGame.dist.getPlayerNotNewFlags()
        for recipe in self.potionGame.recipes:
            if playerLevel >= recipe.level:
                recipe.enabled = True
            else:
                recipe.enabled = False
            if recipe.enabled:
                recipe.haveMade = recipe.potionID not in notNew_list and False
            else:
                recipe.haveMade = True

        self.potionGame.recipes.sort()
        for recipe in self.potionGame.recipes:
            if recipe.questOnly:
                if localAvatar.getInventory():

                    class brewable(Exception):
                        __module__ = __name__

                    try:
                        for currQuest in localAvatar.getInventory(
                        ).getQuestList():
                            bonusComplete = currQuest.isComplete(bonus=True)
                            primaryComplete = currQuest.isComplete()
                            if not bonusComplete or not primaryComplete:
                                tasks = currQuest.getQuestDNA().getTaskDNAs()
                                for currTask in tasks:
                                    if isinstance(currTask, PotionsTaskDNA):
                                        raise (PotionGlobals.getPotionItemID(
                                            recipe.potionID)
                                               == currTask.potionType
                                               and not primaryComplete or
                                               PotionGlobals.getPotionItemID(
                                                   recipe.potionID)
                                               == currTask.potionTypeBonus and
                                               not bonusComplete) and brewable

                    except brewable:
                        pass
                    else:
                        continue
                if recipe.level - playerLevel > 3:
                    if not recipe.questOnly:
                        continue
                    buttonImage = None
                    recipe.loadIngredients()
                    buttonImageScale = 0.0
                    text = recipe.name
                    helptext = recipe.desc
                    if not recipe.haveMade:
                        if len(recipe.ingredients) > 0:
                            iconText = recipe.questOnly and PLocalizer.PotionGui[
                                'QuestLabel']
                            iconTextColor = PiratesGuiGlobals.TextFG13
                        else:
                            iconText = PLocalizer.PotionGui['NewLabel']
                            iconTextColor = PiratesGuiGlobals.TextFG1
                        guiAssets = loader.loadModel(
                            'models/minigames/pir_m_gui_pot_textureCard')
                        buttonImage = guiAssets.find(
                            '**/pir_t_gui_pot_seal').copyTo(NodePath())
                        buttonImageScale = 0.08
                        buttonText = DirectLabel(
                            parent=buttonImage,
                            relief=None,
                            text=iconText,
                            text_scale=PiratesGuiGlobals.TextScaleLarge /
                            buttonImageScale,
                            text_font=PiratesGlobals.getPirateOutlineFont(),
                            text_align=TextNode.ACenter,
                            text_fg=iconTextColor,
                            text_shadow=PiratesGuiGlobals.TextFG14,
                            hpr=(0, 0, 20),
                            pos=(-0.25, 0, 0),
                            textMayChange=0)
                        guiAssets.removeNode()
                    cmd = ((Freebooter.getPaidStatus(localAvatar.doId)
                            or recipe.isFree) and self).potionGame.selectRecipe
                    buttonGeom = None
                    buttonGeomScale = 1
                    buttonGeomPos = (0, 0, 0)
                    args = None
                else:
                    gui = loader.loadModel('models/gui/toplevel_gui')
                    buttonGeom = gui.find('**/pir_t_gui_gen_key_subscriber')
                    buttonGeomScale = 0.16
                    buttonGeomPos = (-0.05, 0, 0.01)
                    cmd = base.localAvatar.guiMgr.showNonPayer
                    args = ['Restricted_Potion_Crafting_Recipe', 9]
                    gui.removeNode()
                button = recipe.enabled and recipe.available and GuiButton.GuiButton(
                    text=(text, text, text, text),
                    canReposition=True,
                    text_wordwrap=0,
                    image_scale=buttonImageScale,
                    image_pos=(-0.04, 0.0, 0.01),
                    image=(buttonImage, buttonImage, buttonImage, buttonImage),
                    geom=buttonGeom,
                    geom_scale=buttonGeomScale,
                    geom_pos=buttonGeomPos,
                    text0_fg=PotionGlobals.TextColor,
                    text1_fg=PiratesGuiGlobals.TextFG0,
                    text2_fg=PiratesGuiGlobals.TextFG15,
                    text3_fg=PotionGlobals.TextColorDisabled,
                    text_align=TextNode.ALeft,
                    text_shadow=None,
                    text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
                    command=cmd,
                    state=DGG.NORMAL,
                    extraArgs=[recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.075, 0,
                                           0.01)
                self.buttons.append(button)
            else:
                button = GuiButton.GuiButton(
                    text=(text, text, text, text),
                    canReposition=True,
                    text_wordwrap=0,
                    image_scale=buttonImageScale,
                    image_pos=(-0.04, 0.0, 0.01),
                    image=(buttonImage, buttonImage, buttonImage, buttonImage),
                    geom=buttonGeom,
                    geom_scale=buttonGeomScale,
                    geom_pos=buttonGeomPos,
                    text0_fg=PotionGlobals.TextColorDisabled,
                    text1_fg=PotionGlobals.TextColorDisabled,
                    text2_fg=PotionGlobals.TextColorDisabled,
                    text3_fg=PotionGlobals.TextColorDisabled,
                    text_shadow=None,
                    text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
                    text_align=TextNode.ALeft,
                    state=DGG.NORMAL,
                    extraArgs=[recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.075, 0,
                                           0.01)
                self.inactiveButtons.append(button)
            self.recipeList.addItem(button)

        self.recipeList.refresh()
        self.lastIncButtonState = self.recipeList.incButton['state']
        self.lastDecButtonState = self.recipeList.decButton['state']
        self.recipeList.incButton['command'] = self.recipeList.scrollBy
        self.recipeList.incButton['extraArgs'] = [1]
        self.recipeList.decButton['command'] = self.recipeList.scrollBy
        self.recipeList.decButton['extraArgs'] = [-1]
        return
Esempio n. 24
0
    def update(self, repId=None, fromUser=0):
        inv = localAvatar.getInventory()
        if not inv:
            self.notify.warning('SkillPage unable to find inventory')
            return
        if self.tabBar == None:
            return
        if self.demo:
            return
        if fromUser:
            self.lastUserSelectedTab = repId
        if repId == None:
            if localAvatar.getGameState() == 'Fishing':
                if self.lastUserSelectedTab:
                    repId = self.lastUserSelectedTab
                else:
                    repId = InventoryType.CannonRep
            elif localAvatar.cannon:
                repId = InventoryType.CannonRep
            elif localAvatar.gameFSM.state == 'ShipPilot':
                repId = InventoryType.SailingRep
            elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
                repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
            elif localAvatar.currentWeaponId and not localAvatar.isWeaponDrawn and self.lastUserSelectedTab:
                repId = self.lastUserSelectedTab
            else:
                repId = InventoryType.CannonRep
        self.setRep(repId)
        self.tabBar.selectTab(str(repId))
        self.repMeter.setCategory(repId)
        self.repMeter.update(inv.getReputation(repId))
        unSpentId = self.getUnspent()
        amt = inv.getStackQuantity(unSpentId)
        if unSpentId in self.localMods:
            amt = self.localMods[unSpentId]
        self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
        if amt > 0:
            self.unspent['text_fg'] = (0.8, 1, 0.8, 1)
        else:
            self.unspent['text_fg'] = (1, 1, 1, 1)
        comboSkills = RadialMenu.ComboSkills(repId, 1)
        totalComboSkills = RadialMenu.ComboSkills(repId, 0)
        activeSkills = RadialMenu.ActiveSkills(repId, 1)
        totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
        passiveSkills = RadialMenu.PassiveSkills(repId, 1)
        totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
        self.linkedSkillIds = {}
        linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
        if linkedSkills:
            for skillId in linkedSkills:
                realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
                self.linkedSkillIds[realSkillId] = skillId

        for excludedSkillId in self.EXCLUDED_SKILLS:
            for skillId in activeSkills:
                if excludedSkillId == skillId:
                    activeSkills.remove(skillId)
                    totalActiveSkills.remove(skillId)

        for spot in self.skillFrames.keys():
            if spot not in totalComboSkills:
                self.skillFrames[spot].hide()

        count = 0
        for skill in totalComboSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in comboSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 1.11
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        count = 0
        for skill in totalActiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            xMod, yMod = self.ringOffset(count)
            xMod *= 0.9
            yMod *= 0.9
            showIcon = skill in activeSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = xMod + 0.53
            y = yMod + 0.615
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            ammo = self.getAmmo(skill)
            if ammo != None and showIcon:
                self.skillFrames[skill].showQuantity = True
                self.skillFrames[skill].updateQuantity(ammo)
            count += 1

        count = 0
        for skill in totalPassiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in passiveSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 0.15
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        self.dataChanged = False
        return
Esempio n. 25
0
 def determineButtonState(self):
     self.guildName = None
     self.guildReal = None
     self.guildRank = None
     self.guildId = base.localAvatar.guildId
     if not self.setupFlag:
         self.setupButtons()
     if self.guildId:
         self.guildName = base.localAvatar.getGuildName()
         self.guildReal = self.guildName
         self.guildRank = base.localAvatar.getGuildRank()
         if self.guildName == '0' or self.guildName == '':
             self.guildName = PLocalizer.GuildDefaultName % self.guildId
         if hasattr(base, 'localAvatar'):
             inv = base.localAvatar.getInventory()
             if inv and not inv.getStackQuantity(InventoryType.NewGuild):
                 base.localAvatar.sendRequestContext(InventoryType.NewGuild)
     if self.nameLabel and self.guildName and self.guildName != PLocalizer.GuildNoGuild and (
             self.guildName != '0' or self.guildName != ''):
         self.nameLabel.show()
         self.nameLabel['text'] = self.guildName
     elif self.nameLabel:
         self.nameLabel.hide()
     rank = base.localAvatar.getGuildRank()
     if rank == 1:
         ranktxt = PLocalizer.GuildRankMember
     else:
         if rank == 2:
             ranktxt = PLocalizer.GuildRankSubLead
         else:
             if rank == 3:
                 ranktxt = PLocalizer.GuildRankLeader
             else:
                 if rank == 4:
                     ranktxt = PLocalizer.GuildRankInviter
                 else:
                     ranktxt = None
                 if self.rankLabel and rank and ranktxt:
                     self.rankLabel['text'] = ranktxt
                     self.rankLabel.show()
                 elif self.rankLabel:
                     ranktxt = PLocalizer.Loading
                     self.rankLabel.hide()
                 if self.memberButton:
                     self.memberButton['state'] = DGG.DISABLED
                 self.renameButton['state'] = DGG.DISABLED
                 self.createButton['state'] = DGG.DISABLED
                 self.leaveButton['state'] = DGG.DISABLED
                 self.inviteButton['state'] = DGG.DISABLED
                 self.redeemInvite['state'] = DGG.NORMAL
                 self.codeInviteOptions['state'] = DGG.DISABLED
                 if self.guildRank > 2 and (self.guildReal == '0'
                                            or self.guildReal == ''
                                            ) and not self.recentlySentName:
                     self.renameButton['state'] = DGG.NORMAL
                     self.redeemInvite['state'] = DGG.DISABLED
                 if self.guildRank > 1:
                     self.inviteButton['state'] = DGG.NORMAL
                     self.redeemInvite['state'] = DGG.DISABLED
                     self.codeInviteOptions['state'] = DGG.NORMAL
             if self.guildRank > 0:
                 self.leaveButton['state'] = DGG.NORMAL
                 self.memberButton['state'] = DGG.NORMAL
                 self.redeemInvite['state'] = DGG.DISABLED
             self.createButton['state'] = DGG.NORMAL
         if Freebooter.FreeGuildRestrict:
             if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                 if self.createButton:
                     self.createButton['state'] = DGG.DISABLED
                 if self.renameButton:
                     self.renameButton['state'] = DGG.DISABLED
     return
Esempio n. 26
0
    def hasQuestOffers(self):
        AvailableQuests = []
        inventory = localAvatar.getInventory()
        prereqExcludes = base.config.GetString('exclude-prereq-quests', '')
        for (questId, questDNA) in QuestDB.QuestDict.items():
            if len(prereqExcludes):
                if questId in prereqExcludes:
                    continue

            prereqs = questDNA.getPrereqs()
            passed = True
            for prereq in prereqs:
                if not prereq.giverCanGive(self.getUniqueId()):
                    passed = False
                    break

                if not prereq.avIsReady(localAvatar):
                    passed = False
                    break

                if questDNA.minLevel > localAvatar.level:
                    passed = False
                    break

                if not base.cr.questDependency.checkDependency(
                        questId, localAvatar.getQuestLadderHistory(), 1):
                    passed = False
                    break

                boolWeapLvlCheck = (questDNA.weapLvlType !=
                                    None) & (questDNA.minWeapLevel > 0)
                if boolWeapLvlCheck & (
                        questDNA.minWeapLevel > getLevelFromTotalReputation(
                            questDNA.weapLvlType,
                            inventory.getReputation(questDNA.weapLvlType))[0]):
                    passed = False
                    break

                if questDNA.getVelvetRoped() and not Freebooter.getPaidStatus(
                        localAvatar.getDoId()):
                    passed = False
                    break

                if questDNA.getAcquireOnce():
                    history = localAvatar.getQuestLadderHistory()
                    questLadderId = base.cr.questDynMap.findQuestLadderInt(
                        questId)
                    containsLadderId = history.count(questLadderId)
                    if containsLadderId:
                        passed = False
                        break

                if questDNA.getHoliday() is not None:
                    holidayId = questDNA.getHoliday()
                    if base.cr.newsManager and not base.cr.newsManager.getHoliday(
                            holidayId):
                        passed = False
                        break

                not base.cr.newsManager.getHoliday(holidayId)

            if prereqs and passed:
                AvailableQuests.append(questDNA)
                continue

        if len(AvailableQuests):
            inventory = localAvatar.getInventory()
            if inventory:
                toRemove = []
                questList = inventory.getQuestList()
                for questDNA in AvailableQuests:
                    questId = questDNA.getQuestId()
                    found = False
                    for quest in questList:
                        if questId == quest.getQuestId(
                        ) or localAvatar.questStatus.hasLadderQuestId(questId):
                            found = True
                            continue

                    if found:
                        toRemove.append(questDNA)
                        continue

                for questDNA in toRemove:
                    AvailableQuests.remove(questDNA)

        for quest in localAvatar.getQuests():
            if quest and quest.getTimeLimit() and quest.canBeReturnedTo(
                    self.getQuestGiverId()):
                return True
                continue

        return len(AvailableQuests) > 0
Esempio n. 27
0
    def _QuestTitleList__makeButtons(self, guiParent, tree):
        i = 0
        for (node, indent) in self._QuestTitleList__graphWalker(tree):
            if not node.questId:
                continue

            if node.hideButton:
                continue

            isContainer = isinstance(node.questDNA,
                                     QuestLadderDNA.QuestContainerDNA)
            text = self._QuestTitleList__getText(indent, node.questId,
                                                 isContainer)
            text_scale = PiratesGuiGlobals.TextScaleLarge
            frameSize = (0, 0.92000000000000004, 0, 0.042000000000000003)
            text_pos = (0.059999999999999998, 0.01)
            textFg = PiratesGuiGlobals.TextFG1
            if indent == 0:
                text_pos = (0.01, 0.01)

            button = DirectButton(parent=guiParent,
                                  relief=None,
                                  frameSize=frameSize,
                                  borderWidth=(0.0050000000000000001,
                                               0.0050000000000000001),
                                  text=text,
                                  text_fg=textFg,
                                  text_scale=text_scale,
                                  text_align=TextNode.ALeft,
                                  text_shadow=PiratesGuiGlobals.TextShadow,
                                  text_pos=text_pos,
                                  command=self.select,
                                  extraArgs=[node.questId])
            questDNA = QuestDB.QuestDict.get(node.questId)
            if questDNA:
                if questDNA.getVelvetRoped():
                    if not Freebooter.getPaidStatus(
                            base.localAvatar.getDoId()):
                        subCard = loader.loadModel('models/gui/toplevel_gui')
                        appendMe = DirectFrame(
                            parent=button,
                            relief=None,
                            pos=(self.width - 0.97999999999999998, 0,
                                 -0.029999999999999999),
                            state=DGG.DISABLED,
                            geom=subCard.find(
                                '**/pir_t_gui_gen_key_subscriber'),
                            geom_scale=0.10000000000000001,
                            geom_pos=(0.059999999999999998, 0,
                                      0.059999999999999998))
                        subCard.removeNode()

            button.accept('press-wheel_up-%s' % button.guiId,
                          self.mouseWheelUp)
            button.accept('press-wheel_down-%s' % button.guiId,
                          self.mouseWheelDown)
            button.indent = indent
            button.questId = node.questId
            self.updateButton(button)
            self.buttons.append(button)
            i += 1
Esempio n. 28
0
    def loadWeaponButtons(self):
        for hotkey in self.hotkeys:
            hotkey.destroy()

        self.hotkeys = []
        for icon in self.icons:
            icon.destroy()

        self.icons = []
        for repMeter in self.repMeters:
            repMeter.destroy()

        self.repMeters = []
        self['frameSize'] = (0, self.ICON_WIDTH * len(self.items) +
                             0.040000000000000001, 0, self.HEIGHT)
        self.setX(-(
            (self.ICON_WIDTH * len(self.items) + 0.040000000000000001) / 2.0))
        topGui = loader.loadModel('models/gui/toplevel_gui')
        kbButton = topGui.find('**/keyboard_button')
        for i in range(len(self.items)):
            if self.items[i]:
                category = WeaponGlobals.getRepId(self.items[i][0])
                icon = DirectFrame(
                    parent=self,
                    state=DGG.DISABLED,
                    relief=None,
                    frameSize=(0, 0.080000000000000002, 0,
                               0.080000000000000002),
                    pos=(self.ICON_WIDTH * i + 0.080000000000000002, 0,
                         0.082000000000000003))
                icon.setTransparency(1)
                hotkeyText = 'F%s' % self.items[i][1]
                hotkey = DirectFrame(parent=icon,
                                     state=DGG.DISABLED,
                                     relief=None,
                                     text=hotkeyText,
                                     text_align=TextNode.ACenter,
                                     text_scale=0.044999999999999998,
                                     text_pos=(0, 0),
                                     text_fg=PiratesGuiGlobals.TextFG2,
                                     text_shadow=PiratesGuiGlobals.TextShadow,
                                     image=kbButton,
                                     image_scale=0.059999999999999998,
                                     image_pos=(0, 0, 0.01),
                                     image_color=(0.5, 0.5,
                                                  0.34999999999999998, 1),
                                     pos=(0, 0, 0.080000000000000002))
                self.hotkeys.append(hotkey)
                category = WeaponGlobals.getRepId(self.items[i][0])
                if Freebooter.getPaidStatus(base.localAvatar.getDoId(
                )) or Freebooter.allowedFreebooterWeapon(category):
                    asset = ItemGlobals.getIcon(self.items[i][0])
                    if asset:
                        texCard = self.card.find('**/%s' % asset)
                        icon['geom'] = texCard
                        icon['geom_scale'] = 0.080000000000000002

                    icon.resetFrameSize()
                    self.icons.append(icon)
                else:
                    texCard = topGui.find('**/pir_t_gui_gen_key_subscriber*')
                    icon['geom'] = texCard
                    icon['geom_scale'] = 0.20000000000000001
                    icon.resetFrameSize()
                    self.icons.append(icon)
                repMeter = DirectWaitBar(
                    parent=icon,
                    relief=DGG.SUNKEN,
                    state=DGG.DISABLED,
                    borderWidth=(0.002, 0.002),
                    range=0,
                    value=0,
                    frameColor=(0.23999999999999999, 0.23999999999999999,
                                0.20999999999999999, 1),
                    barColor=(0.80000000000000004, 0.80000000000000004,
                              0.69999999999999996, 1),
                    pos=(-0.050000000000000003, 0, -0.052499999999999998),
                    hpr=(0, 0, 0),
                    frameSize=(0.0050000000000000001, 0.095000000000000001, 0,
                               0.012500000000000001))
                self.repMeters.append(repMeter)
                inv = base.localAvatar.getInventory()
                if inv:
                    repValue = inv.getReputation(category)
                    (level, leftoverValue
                     ) = ReputationGlobals.getLevelFromTotalReputation(
                         category, repValue)
                    max = ReputationGlobals.getReputationNeededToLevel(
                        category, level)
                    repMeter['range'] = max
                    repMeter['value'] = leftoverValue
Esempio n. 29
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        halfWidth = 0.29999999999999999
        halfHeight = 0.20000000000000001
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ

        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.029999999999999999
        runningVertPosition = 0.29999999999999999
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        typeText = PLocalizer.getJewelryTypeName(ItemGlobals.getType(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        elif rarity == ItemGlobals.COMMON:
            titleColor = PiratesGuiGlobals.TextFG13
        elif rarity == ItemGlobals.RARE:
            titleColor = PiratesGuiGlobals.TextFG4
        elif rarity == ItemGlobals.FAMED:
            titleColor = PiratesGuiGlobals.TextFG5

        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x1slant\x1%s %s\x2' %
                                    (rarityText, typeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.050000000000000003
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        gender = localAvatar.style.gender
        dna = HumanDNA.HumanDNA(gender)
        dna.copy(localAvatar.style)
        bodyShape = localAvatar.style.getBodyShape()
        bodyHeight = localAvatar.style.getBodyHeight()
        bodyOffset = 0.5
        browOffset = 0
        earOffset = 0
        noseOffset = 0
        mouthOffset = 0
        handOffset = 0
        if bodyShape == 0:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.75
                earOffset = 0.65000000000000002
                noseOffset = 0.69999999999999996
                mouthOffset = 0.75
                handOffset = 0.40000000000000002
            elif gender == 'f':
                browOffset = 0.55000000000000004
                earOffset = 0.55000000000000004
                noseOffset = 0.45000000000000001
                mouthOffset = 0.65000000000000002
                handOffset = 0.29999999999999999

        elif bodyShape == 1:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.20000000000000001
                earOffset = 0.20000000000000001
                noseOffset = 0.10000000000000001
                mouthOffset = 0.20000000000000001
                handOffset = 0.20000000000000001
            elif gender == 'f':
                browOffset = 0.5
                earOffset = 0.5
                noseOffset = 0.40000000000000002
                mouthOffset = 0.5
                handOffset = 0.20000000000000001

        elif bodyShape == 2:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.10000000000000001
                earOffset = 0.10000000000000001
                noseOffset = -0.050000000000000003
                mouthOffset = 0.10000000000000001
                handOffset = 0.10000000000000001
            elif gender == 'f':
                browOffset = -0.10000000000000001
                earOffset = -0.10000000000000001
                noseOffset = -0.20000000000000001
                mouthOffset = -0.10000000000000001
                handOffset = -0.10000000000000001

        elif bodyShape == 3:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.20000000000000001
                earOffset = 0.20000000000000001
                noseOffset = 0.050000000000000003
                mouthOffset = 0.20000000000000001
                handOffset = 0.20000000000000001
            elif gender == 'f':
                browOffset = -0.40000000000000002
                earOffset = -0.40000000000000002
                noseOffset = -0.45000000000000001
                mouthOffset = -0.29999999999999999
                handOffset = -0.20000000000000001

        elif bodyShape == 4:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = -0.20000000000000001
                earOffset = -0.20000000000000001
                noseOffset = -0.29999999999999999
                mouthOffset = -0.14999999999999999
                handOffset = -0.050000000000000003
            elif gender == 'f':
                browOffset = 0.10000000000000001
                earOffset = 0.10000000000000001
                noseOffset = 0.0
                mouthOffset = 0.10000000000000001
                handOffset = 0.0

        elif bodyShape == 5:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.10000000000000001
                earOffset = 0.10000000000000001
                noseOffset = -0.050000000000000003
                mouthOffset = 0.10000000000000001
                handOffset = 0.10000000000000001
            elif gender == 'f':
                browOffset = -0.050000000000000003
                earOffset = -0.10000000000000001
                noseOffset = -0.14999999999999999
                mouthOffset = -0.050000000000000003
                handOffset = -0.10000000000000001

        elif bodyShape == 6:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.10000000000000001
                earOffset = 0.10000000000000001
                noseOffset = -0.050000000000000003
                mouthOffset = 0.10000000000000001
                handOffset = 0.10000000000000001
            elif gender == 'f':
                browOffset = 0.40000000000000002
                earOffset = 0.40000000000000002
                noseOffset = 0.25
                mouthOffset = 0.40000000000000002
                handOffset = 0.10000000000000001

        elif bodyShape == 7:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = 0.10000000000000001
                earOffset = 0.10000000000000001
                noseOffset = -0.050000000000000003
                mouthOffset = 0.10000000000000001
                handOffset = 0.10000000000000001
            elif gender == 'f':
                browOffset = 0.0
                earOffset = -0.050000000000000003
                noseOffset = -0.10000000000000001
                mouthOffset = 0.0
                handOffset = -0.050000000000000003

        elif bodyShape == 8:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = -0.10000000000000001
                earOffset = -0.10000000000000001
                noseOffset = -0.20000000000000001
                mouthOffset = -0.050000000000000003
                handOffset = -0.050000000000000003
            elif gender == 'f':
                browOffset = -0.14999999999999999
                earOffset = -0.14999999999999999
                noseOffset = -0.25
                mouthOffset = -0.14999999999999999
                handOffset = -0.10000000000000001

        elif bodyShape == 9:
            bodyOffset = 0.5
            if gender == 'm':
                browOffset = -0.20000000000000001
                earOffset = -0.20000000000000001
                noseOffset = -0.29999999999999999
                mouthOffset = -0.10000000000000001
                handOffset = -0.050000000000000003
            elif gender == 'f':
                browOffset = -0.34999999999999998
                earOffset = -0.34999999999999998
                noseOffset = -0.45000000000000001
                mouthOffset = -0.34999999999999998
                handOffset = -0.20000000000000001

        m = Mat4(Mat4.identMat())
        itemType = ItemGlobals.getType(itemId)
        if itemType == ItemGlobals.BROW:
            jewelType = JewelryGlobals.LBROW
        elif itemType == ItemGlobals.EAR:
            jewelType = JewelryGlobals.LEAR
        elif itemType == ItemGlobals.NOSE:
            jewelType = JewelryGlobals.NOSE
        elif itemType == ItemGlobals.MOUTH:
            jewelType = JewelryGlobals.MOUTH
        elif itemType == ItemGlobals.HAND:
            jewelType = JewelryGlobals.LHAND

        primaryColor = ItemGlobals.getPrimaryColor(itemId)
        secondaryColor = ItemGlobals.getSecondaryColor(itemId)
        if localAvatar.style.gender == 'm':
            maleModelId = ItemGlobals.getMaleModelId(itemId)
            if maleModelId:
                jewelId = maleModelId
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'm'
            else:
                jewelId = ItemGlobals.getFemaleModelId(itemId)
                dna = HumanDNA.HumanDNA('f')
                gender = 'f'
        else:
            femaleModelId = ItemGlobals.getFemaleModelId(itemId)
            if femaleModelId:
                jewelId = femaleModelId
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'f'
            else:
                jewelId = ItemGlobals.getMaleModelId(itemId)
                dna = HumanDNA.HumanDNA('m')
                gender = 'm'
        if jewelType == JewelryGlobals.LBROW:
            dna.setJewelryZone3(jewelId, primaryColor, secondaryColor)
        elif jewelType == JewelryGlobals.LEAR:
            dna.setJewelryZone1(jewelId, primaryColor, secondaryColor)
        elif jewelType == JewelryGlobals.NOSE:
            dna.setJewelryZone5(jewelId, primaryColor, secondaryColor)
        elif jewelType == JewelryGlobals.MOUTH:
            dna.setJewelryZone6(jewelId, primaryColor, secondaryColor)
        elif jewelType == JewelryGlobals.LHAND:
            dna.setJewelryZone7(jewelId, primaryColor, secondaryColor)

        dna.setClothesHat(0, 0)
        self.displayHuman.setDNAString(dna)
        self.displayHuman.generateHuman(gender, self.masterHuman)
        self.displayHuman.stopBlink()
        self.displayHuman.pose('idle', 1)
        lodNode = self.displayHuman.find('**/+LODNode').node()
        lodNode.forceSwitch(lodNode.getHighestSwitch())
        if jewelType == JewelryGlobals.LBROW:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'trs_right_eyebrow').getNetTransform(m)
            rightEyeHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetX = 0.40000000000000002
                offsetZ = -rightEyeHeight + browOffset - bodyHeight * 1.0
                offsetY = 0.25 + bodyOffset
            else:
                offsetX = 0.29999999999999999
                offsetZ = -rightEyeHeight * 0.98999999999999999 + browOffset - bodyHeight * 1.0
                offsetY = 0.14999999999999999 + bodyOffset
            offsetH = -240
        elif jewelType == JewelryGlobals.LEAR:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_trs_left_ear').getNetTransform(m)
            leftEarHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetZ = -leftEarHeight + earOffset - bodyHeight * 1.0
                offsetY = 0.40000000000000002 + bodyOffset
                offsetX = 0.14999999999999999
            else:
                offsetZ = -leftEarHeight * 0.98999999999999999 + earOffset - bodyHeight * 1.0
                offsetY = 0.29999999999999999 + bodyOffset
                offsetX = 0.040000000000000001
            offsetH = -250
        elif jewelType == JewelryGlobals.NOSE:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_trs_mid_nose_bot').getNetTransform(m)
            noseHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetZ = -noseHeight + 0.089999999999999997 + noseOffset - bodyHeight * 0.80000000000000004
                offsetY = 0.45000000000000001 + bodyOffset
            else:
                offsetZ = -noseHeight + 0.10000000000000001 + noseOffset - bodyHeight * 0.80000000000000004
                offsetY = 0.40000000000000002 + bodyOffset
            offsetX = 0.059999999999999998
            offsetH = 180
        elif jewelType == JewelryGlobals.MOUTH:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'trs_lips_top').getNetTransform(m)
            mouthHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -mouthHeight + 0.02 + mouthOffset - bodyHeight * 1.1000000000000001
            offsetY = 0.59999999999999998 + bodyOffset
            offsetX = 0.080000000000000002
            offsetH = 180
        elif jewelType == JewelryGlobals.LHAND:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_left_index01').getNetTransform(m)
            leftIndexHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetZ = -leftIndexHeight + 0.050000000000000003 + handOffset - bodyHeight * 0.5
                offsetX = -0.69999999999999996
                offsetY = 1.25 + bodyOffset
            else:
                offsetZ = -leftIndexHeight + handOffset - bodyHeight * 0.5
                if bodyShape == 4:
                    offsetX = -1.0
                    offsetY = 1.75 + bodyOffset
                elif bodyShape == 3:
                    offsetX = -0.69999999999999996
                    offsetY = 1.25 + bodyOffset
                elif bodyShape == 1:
                    offsetX = -0.69999999999999996
                    offsetY = 1.25 + bodyOffset
                elif bodyShape == 0:
                    offsetX = -0.69999999999999996
                    offsetY = 1.25 + bodyOffset
                else:
                    offsetX = -0.80000000000000004
                    offsetY = 1.25 + bodyOffset
            offsetH = 160
        else:
            offsetZ = 0.0
            offsetY = 0.0
            offsetX = 0.0
            offsetH = 0
        self.displayHuman.setY(offsetY)
        self.displayHuman.setZ(offsetZ)
        self.displayHuman.setX(offsetX)
        self.displayHuman.setH(offsetH)
        self.displayHuman.reparentTo(self.portraitSceneGraph)
        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell and self.cell.container:
            itemCost = int(itemCost * self.cell.container.getItemPriceMult())

        goldLabel = DirectLabel(
            parent=self,
            relief=None,
            image=coinImage,
            image_scale=0.12,
            image_pos=Vec3(0.025000000000000001, 0, -0.02),
            text=str(itemCost),
            text_scale=subtitleScale,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(halfWidth - 0.050000000000000003, 0.0,
                 runningVertPosition + 0.080000000000000002),
            text_pos=(0.0, -textScale))
        labels.append(goldLabel)
        descriptionLabel = DirectLabel(
            parent=self,
            relief=None,
            text=PLocalizer.getItemFlavorText(itemId),
            text_scale=textScale,
            text_wordwrap=halfWidth * 2.0 * (0.94999999999999996 / textScale),
            text_fg=PiratesGuiGlobals.TextFG0,
            text_align=TextNode.ALeft,
            pos=(-halfWidth + textScale * 0.5, 0.0, runningVertPosition),
            text_pos=(0.0, -textScale))
        dHeight = descriptionLabel.getHeight() + 0.02
        runningVertPosition -= dHeight
        runningSize += dHeight
        labels.append(descriptionLabel)
        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.UnlimitedAccessRequirement,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=PiratesGuiGlobals.TextFG6,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)

        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.080000000000000002)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.080000000000000002)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.080000000000000002
        currentHeight = runningVertPosition
        if detailsHeight:
            currentHeight = -detailsHeight

        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.080000000000000002)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.20000000000000001 >= heightMax:
                difference = heightMax - currentHeight
                placement += (0.16800000000000001 /
                              0.20000000000000001) * difference
                currentHeight += difference
            else:
                placement += 0.16800000000000001
                currentHeight += 0.20000000000000001
            middlePanel.setZ(-placement)
            i += 1
        bottomPanel = panels.attachNewNode('bottomPanel')
        detailGui.find('**/bottom_panel').copyTo(bottomPanel)
        bottomPanel.setScale(0.080000000000000002)
        bottomPanel.setZ(-placement)
        bottomPanel.reparentTo(self.helpFrame)
        colorPanel = self.helpFrame.attachNewNode('colorPanel')
        detailGui.find('**/color').copyTo(colorPanel)
        colorPanel.setScale(0.080000000000000002)
        colorPanel.setColor(titleColor)
        colorPanel.reparentTo(self.helpFrame)
        lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
        detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
        lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002,
                                   0.070000000000000007)
        lineBreakTopPanel.setZ(0.0080000000000000002)
        lineBreakTopPanel.reparentTo(self.helpFrame)
        panels.flattenStrong()
        self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                       -(runningSize + vMargin), vMargin)
        totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
        for label in labels:
            label.reparentTo(self.helpFrame)

        if basePosX > 0.0:
            newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
        else:
            newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            (newPosX, newPosZ) = detailsPos

        self.helpFrame.setPos(newPosX, 0, newPosZ)
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        halfWidth = 0.29999999999999999
        halfHeight = 0.20000000000000001
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ

        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.029999999999999999
        runningVertPosition = 0.29999999999999999
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        typeText = PLocalizer.getTattooTypeName(ItemGlobals.getType(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        elif rarity == ItemGlobals.COMMON:
            titleColor = PiratesGuiGlobals.TextFG13
        elif rarity == ItemGlobals.RARE:
            titleColor = PiratesGuiGlobals.TextFG4
        elif rarity == ItemGlobals.FAMED:
            titleColor = PiratesGuiGlobals.TextFG5

        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x001slant\x001%s %s\x002' %
                                    (rarityText, typeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.050000000000000003
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        gender = localAvatar.style.gender
        dna = HumanDNA.HumanDNA(gender)
        dna.copy(localAvatar.style)
        bodyShape = localAvatar.style.getBodyShape()
        bodyHeight = localAvatar.style.getBodyHeight()
        bodyOffset = 0.5
        headOffset = 0
        armOffset = 0
        chestOffset = 0
        if bodyShape == 0:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = 0.69999999999999996
                armOffset = 0.59999999999999998
                chestOffset = 0.5
            elif gender == 'f':
                headOffset = 0.55000000000000004
                armOffset = 0.5
                chestOffset = 0.5

        elif bodyShape == 1:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = 0.10000000000000001
                armOffset = 0.14999999999999999
            elif gender == 'f':
                headOffset = 0.40000000000000002
                armOffset = 0.40000000000000002
                chestOffset = 0.29999999999999999

        elif bodyShape == 2:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = -0.10000000000000001

        elif bodyShape == 3:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = 0.10000000000000001
                armOffset = 0.14999999999999999
            elif gender == 'f':
                headOffset = -0.40000000000000002
                armOffset = -0.20000000000000001
                chestOffset = -0.29999999999999999

        elif bodyShape == 4:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = -0.25
                armOffset = -0.14999999999999999
                chestOffset = -0.25
            elif gender == 'f':
                headOffset = 0.050000000000000003
                armOffset = 0.10000000000000001

        elif bodyShape == 5:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = -0.10000000000000001

        elif bodyShape == 6:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = 0.29999999999999999
                armOffset = 0.29999999999999999
                chestOffset = 0.29999999999999999

        elif bodyShape == 7:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = -0.10000000000000001

        elif bodyShape == 8:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = -0.14999999999999999
                armOffset = -0.10000000000000001
                chestOffset = -0.20000000000000001
            elif gender == 'f':
                headOffset = -0.20000000000000001
                armOffset = -0.10000000000000001
                chestOffset = -0.20000000000000001

        elif bodyShape == 9:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = -0.29999999999999999
                armOffset = -0.20000000000000001
                chestOffset = -0.29999999999999999
            elif gender == 'f':
                headOffset = -0.40000000000000002
                armOffset = -0.20000000000000001
                chestOffset = -0.29999999999999999

        m = Mat4(Mat4.identMat())
        itemType = ItemGlobals.getType(itemId)
        if itemType == ItemGlobals.CHEST:
            tattooType = TattooGlobals.ZONE1
        elif itemType == ItemGlobals.ARM:
            tattooType = TattooGlobals.ZONE2
        elif itemType == ItemGlobals.FACE:
            tattooType = TattooGlobals.ZONE4

        if localAvatar.style.gender == 'm':
            maleModelId = ItemGlobals.getMaleModelId(itemId)
            if maleModelId:
                tattooId = maleModelId
                tattooOrientation = ItemGlobals.getOrientation(
                    ItemGlobals.getMaleOrientation(itemId))
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'm'
            else:
                tattooId = ItemGlobals.getFemaleModelId(itemId)
                tattooOrientation = ItemGlobals.getOrientation(
                    ItemGlobals.getFemaleOrientation(itemId))
                dna = HumanDNA.HumanDNA('f')
                gender = 'f'
        else:
            femaleModelId = ItemGlobals.getFemaleModelId(itemId)
            if femaleModelId:
                tattooId = femaleModelId
                tattooOrientation = ItemGlobals.getOrientation(
                    ItemGlobals.getFemaleOrientation(itemId))
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'f'
            else:
                tattooId = ItemGlobals.getMaleModelId(itemId)
                tattooOrientation = ItemGlobals.getOrientation(
                    ItemGlobals.getMaleOrientation(itemId))
                dna = HumanDNA.HumanDNA('m')
                gender = 'm'
        offsetx = tattooOrientation[0]
        offsety = tattooOrientation[1]
        scale = tattooOrientation[2]
        rotate = tattooOrientation[3]
        color = 0
        S = Vec2(1 / float(scale), 1 / float(scale))
        Iv = Vec2(offsetx, offsety)
        Vm = Vec2(sin(rotate * pi / 180.0), cos(rotate * pi / 180.0))
        Vms = Vec2(Vm[0] * S[0], Vm[1] * S[1])
        Vn = Vec2(Vm[1], -Vm[0])
        Vns = Vec2(Vn[0] * S[0], Vn[1] * S[1])
        F = Vec2(-Vns.dot(Iv) + 0.5, -Vms.dot(Iv) + 0.5)
        if tattooType == 0:
            dna.setClothesShirt(0)
            dna.setClothesVest(0)
            dna.setClothesCoat(0)
            dna.setTattooChest(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 1:
            dna.setClothesShirt(0)
            dna.setClothesCoat(0)
            dna.setTattooZone2(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 2:
            dna.setClothesShirt(0)
            dna.setClothesCoat(0)
            dna.setTattooZone3(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 3:
            dna.setTattooZone4(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 4:
            dna.setTattooZone5(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 5:
            dna.setTattooZone6(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 6:
            dna.setTattooZone7(tattooId, F[0], F[1], S[0], rotate, color)
        elif tattooType == 7:
            dna.setTattooZone8(tattooId, F[0], F[1], S[0], rotate, color)

        self.displayHuman.setDNAString(dna)
        self.displayHuman.generateHuman(gender, self.masterHuman)
        self.displayHuman.stopBlink()
        self.displayHuman.pose('idle', 1)
        lodNode = self.displayHuman.find('**/+LODNode').node()
        lodNode.forceSwitch(lodNode.getHighestSwitch())
        self.displayHuman.reparentTo(self.portraitSceneGraph)
        if tattooType == TattooGlobals.ZONE1:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + chestOffset - bodyHeight * 1.2
            offsetX = 0.0
            offsetY = 3.25 + bodyOffset
            offsetH = 180
        elif tattooType == TattooGlobals.ZONE2:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_left_shoulder').getNetTransform(m)
            leftShoulderHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetZ = -leftShoulderHeight + 1.2 + armOffset - bodyHeight * 0.80000000000000004
                offsetX = 0.0
                offsetY = 2.0 + bodyOffset
            else:
                offsetZ = -leftShoulderHeight + 0.45000000000000001 + armOffset - bodyHeight * 0.80000000000000004
                if bodyShape == 4:
                    offsetY = 2.5 + bodyOffset
                else:
                    offsetY = 2.0 + bodyOffset
                offsetX = -0.20000000000000001
            offsetH = 105
        elif tattooType == TattooGlobals.ZONE4:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_head01').getNetTransform(m)
            headHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = (-headHeight - 0.10000000000000001
                       ) + headOffset - bodyHeight * 1.1000000000000001
            offsetX = 0.0
            offsetY = 1.5 + bodyOffset
            offsetH = 180
        else:
            offsetZ = 0
            offsetY = 0
            offsetX = 0
            offsetH = 0
        self.displayHuman.setY(offsetY)
        self.displayHuman.setZ(offsetZ)
        self.displayHuman.setX(offsetX)
        self.displayHuman.setH(offsetH)
        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell and self.cell.container:
            itemCost = int(itemCost * self.cell.container.getItemPriceMult())

        goldLabel = DirectLabel(
            parent=self,
            relief=None,
            image=coinImage,
            image_scale=0.12,
            image_pos=Vec3(0.025000000000000001, 0, -0.02),
            text=str(itemCost),
            text_scale=subtitleScale,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(halfWidth - 0.050000000000000003, 0.0,
                 runningVertPosition + 0.080000000000000002),
            text_pos=(0.0, -textScale))
        labels.append(goldLabel)
        descriptionLabel = DirectLabel(
            parent=self,
            relief=None,
            text=PLocalizer.getItemFlavorText(itemId),
            text_scale=textScale,
            text_wordwrap=halfWidth * 2.0 * (0.94999999999999996 / textScale),
            text_fg=PiratesGuiGlobals.TextFG0,
            text_align=TextNode.ALeft,
            pos=(-halfWidth + textScale * 0.5, 0.0, runningVertPosition),
            text_pos=(0.0, -textScale))
        dHeight = descriptionLabel.getHeight() + 0.02
        runningVertPosition -= dHeight
        runningSize += dHeight
        labels.append(descriptionLabel)
        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.UnlimitedAccessRequirement,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=PiratesGuiGlobals.TextFG6,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)

        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.080000000000000002)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.080000000000000002)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.080000000000000002
        currentHeight = runningVertPosition
        if detailsHeight:
            currentHeight = -detailsHeight

        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.080000000000000002)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.20000000000000001 >= heightMax:
                difference = heightMax - currentHeight
                placement += (0.16800000000000001 /
                              0.20000000000000001) * difference
                currentHeight += difference
            else:
                placement += 0.16800000000000001
                currentHeight += 0.20000000000000001
            middlePanel.setZ(-placement)
            i += 1
        bottomPanel = panels.attachNewNode('bottomPanel')
        detailGui.find('**/bottom_panel').copyTo(bottomPanel)
        bottomPanel.setScale(0.080000000000000002)
        bottomPanel.setZ(-placement)
        bottomPanel.reparentTo(self.helpFrame)
        colorPanel = self.helpFrame.attachNewNode('colorPanel')
        detailGui.find('**/color').copyTo(colorPanel)
        colorPanel.setScale(0.080000000000000002)
        colorPanel.setColor(titleColor)
        colorPanel.reparentTo(self.helpFrame)
        lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
        detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
        lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002,
                                   0.070000000000000007)
        lineBreakTopPanel.setZ(0.0080000000000000002)
        lineBreakTopPanel.reparentTo(self.helpFrame)
        panels.flattenStrong()
        self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                       -(runningSize + vMargin), vMargin)
        totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
        for label in labels:
            label.reparentTo(self.helpFrame)

        if basePosX > 0.0:
            newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
        else:
            newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            (newPosX, newPosZ) = detailsPos

        self.helpFrame.setPos(newPosX, 0, newPosZ)
    def refreshList(self, setKey=0):
        if setKey == 0 or setKey == None:
            return None

        if self.currentDisplay != 0:
            oldSize = CollectionMap.Collection_Set_Sizes.get(self.currentDisplay)
            for loopItr in range(oldSize):
                curNum = self.currentDisplay + loopItr + 1
                if curNum in self.setPics:
                    self.setPics[curNum].hide()

                self.setFrames[curNum].hide()

        self.currentDisplay = setKey
        self.setLabel["text"] = PLocalizer.Collections[setKey]
        inv = localAvatar.getInventory()
        if not inv:
            return None

        setCount = 0
        heightOffset = 0
        setSize = CollectionMap.Collection_Set_Sizes.get(setKey)
        gui = loader.loadModel("models/gui/toplevel_gui")
        for loopItr in range(setSize):
            setItem = setKey + 1 + loopItr
            rowSpot = loopItr % 4
            colSpot = loopItr / 4
            localHeight = PiratesGuiGlobals.InventoryPanelHeight - 0.20000000000000001
            howMany = inv.getStackQuantity(setItem)
            if setItem in CollectionMap.Collection_Set_Locked:
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    isLocked = True
                else:
                    isLocked = False
            else:
                isLocked = False
            if isLocked or howMany > 0:
                if setItem in self.setPics:
                    self.setPics[setItem].show()
                    self.setFrames[setItem].show()
                else:
                    frameImg = gui.find("**/treasure_w_b_slot_full")
                    self.setFrames[setItem] = DirectFrame(
                        parent=self,
                        relief=None,
                        image=frameImg,
                        image_scale=0.40000000000000002,
                        image_pos=(0, 0, 0),
                        pos=(
                            0.28000000000000003 + 0.17999999999999999 * rowSpot,
                            0,
                            localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                        ),
                    )
                    pic_name = CollectionMap.Assets[setItem]
                    if isLocked:
                        tex = gui.find("**/pir_t_gui_gen_key_subscriber")
                        use_scale = 0.25
                        self.setPics[setItem] = DirectButton(
                            parent=self,
                            relief=None,
                            image=tex,
                            image_scale=use_scale,
                            image_pos=(0, 0, 0),
                            pos=(
                                0.28000000000000003 + 0.17999999999999999 * rowSpot,
                                0,
                                localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                            ),
                            text=PLocalizer.Collections[setItem],
                            text_fg=PiratesGuiGlobals.TextFG2,
                            text_align=TextNode.ACenter,
                            text_wordwrap=6,
                            text_scale=0.025000000000000001,
                            text_pos=(0, -0.085000000000000006, 0),
                            command=base.localAvatar.guiMgr.showNonPayer,
                            extraArgs=["Restricted_Treasure_Selection", 7],
                        )
                    else:
                        tex = self.card.find("**/%s*" % pic_name)
                        use_scale = 0.39000000000000001
                        self.setPics[setItem] = DirectButton(
                            parent=self,
                            relief=None,
                            image=tex,
                            image_scale=use_scale,
                            image_pos=(0, 0, 0),
                            pos=(
                                0.28000000000000003 + 0.17999999999999999 * rowSpot,
                                0,
                                localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                            ),
                            command=self.clickedTreasure,
                            extraArgs=[setItem],
                            text=PLocalizer.Collections[setItem],
                            text_fg=PiratesGuiGlobals.TextFG2,
                            text_align=TextNode.ACenter,
                            text_wordwrap=6,
                            text_scale=0.025000000000000001,
                            text_pos=(0, -0.085000000000000006, 0),
                        )
                    self.setPics[setItem].setTransparency(1)
                if setItem in CollectionMap.Collection_Needed:
                    howManyINeed = CollectionMap.Collection_Needed[setItem]
                else:
                    howManyINeed = 1
                if setItem in CollectionMap.Collection_SingleNumeric:
                    if howMany > 0:
                        if howMany == 1:
                            weightTxt = "Lb"
                        else:
                            weightTxt = "Lbs"
                        if setItem in self.setHowMany:
                            self.setHowMany[setItem]["text"] = "%d %s" % (howMany, weightTxt)
                        else:
                            self.setHowMany[setItem] = DirectLabel(
                                parent=self.setPics[setItem],
                                relief=None,
                                text="%d %s" % (howMany, weightTxt),
                                text_align=TextNode.ARight,
                                text_scale=0.040000000000000001,
                                text_fg=PiratesGuiGlobals.TextFG2,
                                text_shadow=PiratesGuiGlobals.TextShadow,
                                textMayChange=1,
                                pos=(0.080000000000000002, 0, -0.050000000000000003),
                                text_font=PiratesGlobals.getInterfaceOutlineFont(),
                            )

                elif setItem in self.setHowMany:
                    if howManyINeed < 2:
                        self.setHowMany[setItem].hide()
                    else:
                        self.setHowMany[setItem]["text"] = "%d/%d" % (howMany, howManyINeed)
                        self.setHowMany[setItem].show()
                elif howMany > 1:
                    self.setHowMany[setItem] = DirectLabel(
                        parent=self.setPics[setItem],
                        relief=None,
                        text="%d/%d" % (howMany, howManyINeed),
                        text_align=TextNode.ARight,
                        text_scale=0.040000000000000001,
                        text_fg=PiratesGuiGlobals.TextFG2,
                        text_shadow=PiratesGuiGlobals.TextShadow,
                        textMayChange=1,
                        pos=(0.080000000000000002, 0, -0.050000000000000003),
                        text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    )

                if isLocked:
                    if setItem in self.setHowMany:
                        self.setHowMany[setItem].hide()

            if setItem in self.setFrames:
                self.setFrames[setItem].show()
                continue
            frameImg = gui.find("**/treasure_w_b_slot_empty")
            self.setFrames[setItem] = DirectFrame(
                parent=self,
                relief=None,
                image=frameImg,
                image_scale=0.40000000000000002,
                image_pos=(0, 0, 0),
                pos=(
                    0.28000000000000003 + 0.17999999999999999 * rowSpot,
                    0,
                    localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot,
                ),
            )

        gui.removeNode()
 def refreshList(self, setKey = 0):
     if setKey == 0 or setKey == None:
         return None
     
     if self.currentDisplay != 0:
         oldSize = CollectionMap.Collection_Set_Sizes.get(self.currentDisplay)
         for loopItr in range(oldSize):
             curNum = self.currentDisplay + loopItr + 1
             if curNum in self.setPics:
                 self.setPics[curNum].hide()
             
             self.setFrames[curNum].hide()
         
     
     self.currentDisplay = setKey
     self.setLabel['text'] = PLocalizer.Collections[setKey]
     inv = localAvatar.getInventory()
     if not inv:
         return None
     
     setCount = 0
     heightOffset = 0
     setSize = CollectionMap.Collection_Set_Sizes.get(setKey)
     gui = loader.loadModel('models/gui/toplevel_gui')
     for loopItr in range(setSize):
         setItem = setKey + 1 + loopItr
         rowSpot = loopItr % 4
         colSpot = loopItr / 4
         localHeight = PiratesGuiGlobals.InventoryPanelHeight - 0.20000000000000001
         howMany = inv.getStackQuantity(setItem)
         if setItem in CollectionMap.Collection_Set_Locked:
             if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                 isLocked = True
             else:
                 isLocked = False
         else:
             isLocked = False
         if isLocked or howMany > 0:
             if setItem in self.setPics:
                 self.setPics[setItem].show()
                 self.setFrames[setItem].show()
             else:
                 frameImg = gui.find('**/treasure_w_b_slot_full')
                 self.setFrames[setItem] = DirectFrame(parent = self, relief = None, image = frameImg, image_scale = 0.40000000000000002, image_pos = (0, 0, 0), pos = (0.28000000000000003 + 0.17999999999999999 * rowSpot, 0, localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot))
                 pic_name = CollectionMap.Assets[setItem]
                 if isLocked:
                     tex = gui.find('**/pir_t_gui_gen_key_subscriber')
                     use_scale = 0.25
                     self.setPics[setItem] = DirectButton(parent = self, relief = None, image = tex, image_scale = use_scale, image_pos = (0, 0, 0), pos = (0.28000000000000003 + 0.17999999999999999 * rowSpot, 0, localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot), text = PLocalizer.Collections[setItem], text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_wordwrap = 6, text_scale = 0.025000000000000001, text_pos = (0, -0.085000000000000006, 0), command = base.localAvatar.guiMgr.showNonPayer, extraArgs = [
                         'Restricted_Treasure_Selection',
                         7])
                 else:
                     tex = self.card.find('**/%s*' % pic_name)
                     use_scale = 0.39000000000000001
                     self.setPics[setItem] = DirectButton(parent = self, relief = None, image = tex, image_scale = use_scale, image_pos = (0, 0, 0), pos = (0.28000000000000003 + 0.17999999999999999 * rowSpot, 0, localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot), command = self.clickedTreasure, extraArgs = [
                         setItem], text = PLocalizer.Collections[setItem], text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_wordwrap = 6, text_scale = 0.025000000000000001, text_pos = (0, -0.085000000000000006, 0))
                 self.setPics[setItem].setTransparency(1)
             if setItem in CollectionMap.Collection_Needed:
                 howManyINeed = CollectionMap.Collection_Needed[setItem]
             else:
                 howManyINeed = 1
             if setItem in CollectionMap.Collection_SingleNumeric:
                 if howMany > 0:
                     if howMany == 1:
                         weightTxt = 'Lb'
                     else:
                         weightTxt = 'Lbs'
                     if setItem in self.setHowMany:
                         self.setHowMany[setItem]['text'] = '%d %s' % (howMany, weightTxt)
                     else:
                         self.setHowMany[setItem] = DirectLabel(parent = self.setPics[setItem], relief = None, text = '%d %s' % (howMany, weightTxt), text_align = TextNode.ARight, text_scale = 0.040000000000000001, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.080000000000000002, 0, -0.050000000000000003), text_font = PiratesGlobals.getInterfaceOutlineFont())
                 
             elif setItem in self.setHowMany:
                 if howManyINeed < 2:
                     self.setHowMany[setItem].hide()
                 else:
                     self.setHowMany[setItem]['text'] = '%d/%d' % (howMany, howManyINeed)
                     self.setHowMany[setItem].show()
             elif howMany > 1:
                 self.setHowMany[setItem] = DirectLabel(parent = self.setPics[setItem], relief = None, text = '%d/%d' % (howMany, howManyINeed), text_align = TextNode.ARight, text_scale = 0.040000000000000001, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.080000000000000002, 0, -0.050000000000000003), text_font = PiratesGlobals.getInterfaceOutlineFont())
             
             if isLocked:
                 if setItem in self.setHowMany:
                     self.setHowMany[setItem].hide()
                 
             
         if setItem in self.setFrames:
             self.setFrames[setItem].show()
             continue
         frameImg = gui.find('**/treasure_w_b_slot_empty')
         self.setFrames[setItem] = DirectFrame(parent = self, relief = None, image = frameImg, image_scale = 0.40000000000000002, image_pos = (0, 0, 0), pos = (0.28000000000000003 + 0.17999999999999999 * rowSpot, 0, localHeight - 0.35999999999999999 - 0.17999999999999999 * colSpot))
     
     gui.removeNode()
Esempio n. 33
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem or self.manager.locked or cell.isEmpty(
        ) or self.isEmpty() or not self.itemTuple:
            self.notify.debug(' early exit')
            return
        inv = localAvatar.getInventory()
        if not inv:
            return
        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
        border = self.SkillIcons.find('**/base')
        halfWidth = 0.3
        halfHeight = 0.2
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ
        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.03
        runningVertPosition = 0.3
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        itemColor = 'itemRed'
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        subtypeText = PLocalizer.getItemSubtypeName(
            ItemGlobals.getSubtype(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
            itemColor = 'itemBrown'
        else:
            if rarity == ItemGlobals.COMMON:
                titleColor = PiratesGuiGlobals.TextFG13
                itemColor = 'itemYellow'
            else:
                if rarity == ItemGlobals.RARE:
                    titleColor = PiratesGuiGlobals.TextFG4
                    itemColor = 'itemGreen'
                else:
                    if rarity == ItemGlobals.FAMED:
                        titleColor = PiratesGuiGlobals.TextFG5
                        itemColor = 'itemBlue'
        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.07
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x01slant\x01%s %s\x02' %
                                    (rarityText, subtypeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.05
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        itemType = ItemGlobals.getType(itemId)
        itemSubtype = ItemGlobals.getSubtype(itemId)
        model = ItemGlobals.getModel(itemId)
        if model:
            if itemType == ItemGlobals.GRENADE:
                self.realItem = loader.loadModel('models/ammunition/' + model)
            else:
                self.realItem = loader.loadModel('models/handheld/' + model)
            if self.realItem:
                spinBlur = self.realItem.find('**/motion_blur')
                if spinBlur:
                    spinBlur.hide()
                if itemSubtype == ItemGlobals.MUSKET:
                    bayonetPart = self.realItem.find('**/bayonet')
                    if bayonetPart:
                        bayonetPart.stash()
                posHpr = ItemGlobals.getModelPosHpr(model)
                if posHpr:
                    self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                    self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
                else:
                    if itemType == ItemGlobals.SWORD:
                        self.realItem.setPos(-1.5, 3.0, -0.3)
                        self.realItem.setHpr(90, 170, -90)
                    else:
                        if itemSubtype in (ItemGlobals.MUSKET,
                                           ItemGlobals.BAYONET):
                            self.realItem.setPos(-1.2, 3.0, -0.1)
                            self.realItem.setHpr(0, 135, 10)
                        else:
                            if itemSubtype == ItemGlobals.BLUNDERBUSS:
                                self.realItem.setPos(-0.3, 2.0, 0.0)
                                self.realItem.setHpr(0, 90, 0)
                            else:
                                if itemType == ItemGlobals.GUN:
                                    self.realItem.setPos(-0.5, 2.0, -0.2)
                                    self.realItem.setHpr(0, 90, 0)
                                else:
                                    if itemType == ItemGlobals.DOLL:
                                        self.realItem.setPos(0.0, 1.9, -0.1)
                                        self.realItem.setHpr(0, 90, 180)
                                    else:
                                        if itemType == ItemGlobals.DAGGER:
                                            self.realItem.setPos(
                                                -1.0, 2.0, -0.3)
                                            self.realItem.setHpr(90, 170, -90)
                                        else:
                                            if itemType == ItemGlobals.GRENADE:
                                                self.realItem.setPos(
                                                    0.0, 3.5, -0.2)
                                                self.realItem.setHpr(0, 0, 0)
                                            else:
                                                if itemType == ItemGlobals.STAFF:
                                                    self.realItem.setPos(
                                                        -0.4, 3.0, -0.3)
                                                    self.realItem.setHpr(
                                                        -90, 15, -90)
                self.realItem.reparentTo(self.portraitSceneGraph)
        iHeight = 0.175
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.06)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell:
            if self.cell.container:
                itemCost = int(itemCost *
                               self.cell.container.getItemPriceMult())
            goldLabel = DirectLabel(parent=self,
                                    relief=None,
                                    image=coinImage,
                                    image_scale=0.12,
                                    image_pos=Vec3(0.025, 0, -0.02),
                                    text=str(itemCost),
                                    text_scale=subtitleScale,
                                    text_align=TextNode.ARight,
                                    text_fg=PiratesGuiGlobals.TextFG1,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    pos=(halfWidth - 0.05, 0.0,
                                         runningVertPosition + 0.08),
                                    text_pos=(0.0, -textScale))
            labels.append(goldLabel)
            infoText = PLocalizer.ItemAttackStrength % (
                '\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getPower(itemId)))
            if itemType == ItemGlobals.GUN:
                infoText += '     %s' % (
                    PLocalizer.ItemBarrels %
                    ('\x01%s\x01%s\x02' %
                     (itemColor, ItemGlobals.getBarrels(itemId))))
                infoText += '     %s' % (
                    PLocalizer.ItemRangeStrength %
                    ('\x01%s\x01%s\x02' %
                     (itemColor,
                      PLocalizer.getItemRangeName(
                          WeaponGlobals.getRange(itemId)))))
            infoLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text=infoText,
                                    text_scale=textScale,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
            iHeight = 0.08
            runningVertPosition -= iHeight
            runningSize += iHeight
            labels.append(infoLabel)
            specialAttack = ItemGlobals.getSpecialAttack(itemId)
            if specialAttack:
                attackIcon = self.SkillIcons.find(
                    '**/%s' % WeaponGlobals.getSkillIcon(specialAttack))
                specialAttackNameLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    image=border,
                    image_scale=0.1,
                    geom=attackIcon,
                    geom_scale=0.1,
                    image_pos=(-0.07, 0.0, -0.05),
                    geom_pos=(-0.07, 0.0, -0.05),
                    text=PLocalizer.getInventoryTypeName(specialAttack),
                    text_scale=PiratesGuiGlobals.TextScaleLarge,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    text_fg=titleColor,
                    text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                specialAttackRankLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.ItemRank %
                    ItemGlobals.getSpecialAttackRank(itemId),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ARight,
                    pos=(halfWidth - textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                specialAttackType = WeaponGlobals.getSkillTrack(specialAttack)
                if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX:
                    specialAttackTypeText = PLocalizer.BreakAttackSkill
                else:
                    if specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX:
                        specialAttackTypeText = PLocalizer.DefenseSkill
                    else:
                        specialAttackTypeText = PLocalizer.WeaponSkill
                specialAttackTypeLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=specialAttackTypeText,
                    text_scale=0.0335,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition -
                         PiratesGuiGlobals.TextScaleLarge),
                    text_pos=(0.0, -textScale))
                specialAttackInfo = PLocalizer.SkillDescriptions.get(
                    specialAttack)
                specialAttackDescriptionText = specialAttackInfo[1]
                specialAttackDescriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=specialAttackDescriptionText,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition -
                         (specialAttackNameLabel.getHeight() +
                          specialAttackTypeLabel.getHeight() - 0.06)),
                    text_pos=(0.0, -textScale))
                saHeight = specialAttackNameLabel.getHeight(
                ) + specialAttackTypeLabel.getHeight(
                ) + specialAttackDescriptionLabel.getHeight() - 0.04
                runningVertPosition -= saHeight
                runningSize += saHeight
                labels.append(specialAttackNameLabel)
                labels.append(specialAttackRankLabel)
                labels.append(specialAttackTypeLabel)
                labels.append(specialAttackDescriptionLabel)
            attributes = ItemGlobals.getAttributes(itemId)
            for i in range(0, len(attributes)):
                attributeIcon = self.SkillIcons.find(
                    '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))
                if not attributeIcon:
                    attributeIcon = self.BuffIcons.find(
                        '**/%s' %
                        ItemGlobals.getAttributeIcon(attributes[i][0]))
                attributeNameLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    image=border,
                    image_scale=0.05,
                    geom=attributeIcon,
                    geom_scale=0.05,
                    image_pos=(-0.07, 0.0, -0.03),
                    geom_pos=(-0.07, 0.0, -0.03),
                    text=PLocalizer.getItemAttributeName(attributes[i][0]),
                    text_scale=PiratesGuiGlobals.TextScaleLarge,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    text_fg=titleColor,
                    text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                attributeRankLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.ItemRank % attributes[i][1],
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ARight,
                    pos=(halfWidth - textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                if attributeNameLabel.getHeight() > 0.075:
                    attributeNameSpace = 0.08
                else:
                    attributeNameSpace = PiratesGuiGlobals.TextScaleLarge
                attributeDescriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.getItemAttributeDescription(
                        attributes[i][0]),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition - attributeNameSpace),
                    text_pos=(0.0, -textScale))
                aHeight = attributeNameLabel.getHeight(
                ) + attributeDescriptionLabel.getHeight()
                runningVertPosition -= aHeight + splitHeight
                runningSize += aHeight + splitHeight
                labels.append(attributeNameLabel)
                labels.append(attributeRankLabel)
                labels.append(attributeDescriptionLabel)

            skillBoosts = ItemGlobals.getSkillBoosts(itemId)
            for i in range(0, len(skillBoosts)):
                skillId, skillBoost = skillBoosts[i]
                linkedSkills = ItemGlobals.getLinkedSkills(itemId)
                if linkedSkills:
                    for id in linkedSkills:
                        if skillId == WeaponGlobals.getLinkedSkillId(id):
                            skillId = id

                boostIcon = self.SkillIcons.find(
                    '**/%s' % WeaponGlobals.getSkillIcon(skillId))
                boostNameLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    image=border,
                    image_scale=0.05,
                    geom=boostIcon,
                    geom_scale=0.05,
                    image_pos=(-0.07, 0.0, -0.03),
                    geom_pos=(-0.07, 0.0, -0.03),
                    text=PLocalizer.ItemBoost %
                    PLocalizer.getInventoryTypeName(skillId),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                boostRankLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text='+%s' % str(skillBoost),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ARight,
                    pos=(halfWidth - textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                bHeight = boostNameLabel.getHeight()
                runningVertPosition -= bHeight + splitHeight
                runningSize += bHeight + splitHeight
                labels.append(boostNameLabel)
                labels.append(boostRankLabel)

            description = PLocalizer.getItemFlavorText(itemId)
            if description != '':
                descriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=description,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.95 / textScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                dHeight = descriptionLabel.getHeight() + 0.02
                runningVertPosition -= dHeight
                runningSize += dHeight
                labels.append(descriptionLabel)
            weaponLevel = 0
            weaponRepId = WeaponGlobals.getRepId(itemId)
            weaponRep = inv.getReputation(weaponRepId)
            weaponReq = ItemGlobals.getWeaponRequirement(itemId)
            weaponText = None
            trainingToken = EconomyGlobals.getItemTrainingReq(itemId)
            trainingAmt = inv.getItemQuantity(trainingToken)
            if weaponReq:
                weaponLevel = ReputationGlobals.getLevelFromTotalReputation(
                    weaponRepId, weaponRep)[0]
                if weaponLevel < weaponReq:
                    weaponColor = PiratesGuiGlobals.TextFG6
                else:
                    weaponColor = (0.4, 0.4, 0.4, 1.0)
                weaponText = PLocalizer.ItemLevelRequirement % (
                    weaponReq, PLocalizer.getItemTypeName(itemType))
            else:
                if trainingAmt == 0:
                    weaponColor = PiratesGuiGlobals.TextFG6
                    weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(
                        itemType)
            if trainingAmt == 0:
                if itemType == ItemGlobals.GUN:
                    base.localAvatar.sendRequestContext(
                        InventoryType.GunTrainingRequired)
                elif itemType == ItemGlobals.DOLL:
                    base.localAvatar.sendRequestContext(
                        InventoryType.DollTrainingRequired)
                elif itemType == ItemGlobals.DAGGER:
                    base.localAvatar.sendRequestContext(
                        InventoryType.DaggerTrainingRequired)
                elif itemType == ItemGlobals.STAFF:
                    base.localAvatar.sendRequestContext(
                        InventoryType.StaffTrainingRequired)
            if weaponText:
                weaponReqLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=weaponText,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=weaponColor,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                wHeight = weaponReqLabel.getHeight()
                runningVertPosition -= wHeight
                runningSize += wHeight
                labels.append(weaponReqLabel)
            if not Freebooter.getPaidStatus(localAvatar.getDoId()):
                if rarity != ItemGlobals.CRUDE:
                    unlimitedLabel = DirectLabel(
                        parent=self,
                        relief=None,
                        text=PLocalizer.UnlimitedAccessRequirement,
                        text_scale=textScale,
                        text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                        text_fg=PiratesGuiGlobals.TextFG6,
                        text_shadow=PiratesGuiGlobals.TextShadow,
                        text_align=TextNode.ACenter,
                        pos=(0.0, 0.0, runningVertPosition),
                        text_pos=(0.0, -textScale))
                    uHeight = unlimitedLabel.getHeight()
                    runningVertPosition -= uHeight
                    runningSize += uHeight
                    labels.append(unlimitedLabel)
            runningVertPosition -= 0.02
            runningSize += 0.02
            panels = self.helpFrame.attachNewNode('panels')
            topPanel = panels.attachNewNode('middlePanel')
            detailGui.find('**/top_panel').copyTo(topPanel)
            topPanel.setScale(0.08)
            topPanel.reparentTo(self.helpFrame)
            middlePanel = panels.attachNewNode('middlePanel')
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.08)
            middlePanel.reparentTo(self.helpFrame)
            placement = 0
            i = 0
            heightMax = -0.08
            currentHeight = runningVertPosition
            if detailsHeight:
                currentHeight = -detailsHeight
            while currentHeight < heightMax:
                middlePanel = panels.attachNewNode('middlePanel%s' % 1)
                detailGui.find('**/middle_panel').copyTo(middlePanel)
                middlePanel.setScale(0.08)
                middlePanel.reparentTo(self.helpFrame)
                if currentHeight + 0.2 >= heightMax:
                    difference = heightMax - currentHeight
                    placement += 0.168 / 0.2 * difference
                    currentHeight += difference
                else:
                    placement += 0.168
                    currentHeight += 0.2
                middlePanel.setZ(-placement)
                i += 1

            bottomPanel = panels.attachNewNode('bottomPanel')
            detailGui.find('**/bottom_panel').copyTo(bottomPanel)
            bottomPanel.setScale(0.08)
            bottomPanel.setZ(-placement)
            bottomPanel.reparentTo(self.helpFrame)
            colorPanel = panels.attachNewNode('colorPanel')
            detailGui.find('**/color').copyTo(colorPanel)
            colorPanel.setScale(0.08)
            colorPanel.setColor(titleColor)
            colorPanel.reparentTo(self.helpFrame)
            lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
            detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
            lineBreakTopPanel.setScale(0.08, 0.08, 0.07)
            lineBreakTopPanel.setZ(0.008)
            lineBreakTopPanel.reparentTo(self.helpFrame)
            lineBreakBottomPanel = panels.attachNewNode('lineBreakBottomPanel')
            detailGui.find('**/line_break_bottom').copyTo(lineBreakBottomPanel)
            lineBreakBottomPanel.setScale(0.08, 0.08, 0.07)
            lineBreakBottomPanel.setZ(-0.015)
            lineBreakBottomPanel.reparentTo(self.helpFrame)
            panels.flattenStrong()
            self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                           -(runningSize + vMargin), vMargin)
            totalHeight = self.helpFrame.getHeight() - 0.1
            for label in labels:
                label.reparentTo(self.helpFrame)

            if basePosX > 0.0:
                newPosX = basePosX - (halfWidth + cellSizeX * 0.45)
            else:
                newPosX = basePosX + (halfWidth + cellSizeX * 0.45)
            newPosZ = basePosZ > 0.0 and basePosZ + cellSizeZ * 0.45
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
    def refresh(self):
        inv = localAvatar.getInventory()
        origRank = self.rank
        if inv:
            invType = TitleGlobals.getInventoryType(self.titleId)
            if self.titleId == TitleGlobals.ShipPVPTitle:
                self.expPoints = localAvatar.getInventory().getStackQuantity(
                    InventoryType.PVPTotalInfamySea)
            elif self.titleId == TitleGlobals.LandPVPTitle:
                self.expPoints = localAvatar.getInventory().getStackQuantity(
                    InventoryType.PVPTotalInfamyLand)
            elif invType:
                self.expPoints = inv.getStackQuantity(invType)
            else:
                self.expPoints = 0
                if self.titleId == TitleGlobals.FounderTitle and localAvatar.getFounder(
                ):
                    self.expPoints = 1

            self.rank = TitleGlobals.getRank(self.titleId, self.expPoints)
            self.maxRank = TitleGlobals.getMaxRank(self.titleId)
            self.expTarget = TitleGlobals.getBreakpoints(self.titleId)[min(
                self.rank + 1, self.maxRank)]
            self.expBase = TitleGlobals.getBreakpoints(self.titleId)[self.rank]

        if self.titleNameFrame:
            self.titleNameFrame['text'] = TitleGlobals.getTitleRankName(
                self.titleId, self.expPoints)

        if self.expMeter:
            value = 0
            if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
                value = int((self.expPoints - self.expBase) * 100 /
                            (self.expTarget - self.expBase))

            self.expMeter['value'] = value

        if self.expMeterText:
            if self.rank >= self.maxRank:
                self.expBase = 0
                self.expTarget = 0

            text = '0 / 0'
            if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
                text = '%s / %s' % (self.expPoints - self.expBase,
                                    self.expTarget - self.expBase)

            self.expMeterText['text'] = text

        if self.iconFrame:
            icName = TitleGlobals.getIconName(self.titleId, self.rank)
            if icName:
                img = self.iconModel.find('**/' + icName)
            else:
                img = None
            self.iconFrame['image'] = img
            imgScale = TitleGlobals.getScale(self.titleId)
            self.iconFrame['image_scale'] = (0.065000000000000002 * imgScale,
                                             1,
                                             0.065000000000000002 * imgScale)

        titleOnOff = [PLocalizer.TitleOff, PLocalizer.TitleOn]
        if self.rank != origRank:
            if self.landActive:
                self.titlesPage.setLandActive(self.panelIndex, self.landActive)

            if self.seaActive:
                self.titlesPage.setSeaActive(self.panelIndex, self.seaActive)

        if self.rank == 0 or not Freebooter.getPaidStatus(localAvatar.doId):
            self.landButton.hide()
            self.seaButton.hide()
        else:
            self.landButton.show()
            self.seaButton.show()
Esempio n. 35
0
    def __init__(self, callback, skillId, skillRank):
        if not AmmoPanelButton.SkillIcons:
            AmmoPanelButton.SkillIcons = loader.loadModel(
                'models/textureCards/skillIcons')
            AmmoPanelButton.Image = (
                AmmoPanelButton.SkillIcons.find('**/base'),
                AmmoPanelButton.SkillIcons.find('**/base_down'),
                AmmoPanelButton.SkillIcons.find('**/base_over'))

        self.locked = True
        self.purchaseable = True
        self.cost = CannonDefenseGlobals.getDefenseCannonAmmoCost(skillId)
        self.amount = CannonDefenseGlobals.getDefenseCannonAmmoAmount(skillId)
        if self.amount == -1:
            self.amount = PLocalizer.Unlimited

        self.skillId = skillId
        self.skillRank = skillRank
        self.infoBox = None
        self.flashIval = None
        asset = RadialMenu.getSkillIconName(skillId, 0)
        geom = AmmoPanelButton.SkillIcons.find('**/%s' % asset)
        self.geom = geom
        if self.locked:
            asset = None
            geom = None

        DirectButton.__init__(self,
                              relief=None,
                              pos=(0, 0, 0),
                              text='?',
                              text_scale=0.10000000000000001,
                              text_fg=PiratesGuiGlobals.TextFG2,
                              text_shadow=PiratesGuiGlobals.TextShadow,
                              text_pos=(0.0050000000000000001,
                                        -0.035000000000000003),
                              text_align=TextNode.ACenter,
                              image=AmmoPanelButton.Image,
                              image_scale=0.12,
                              geom=geom,
                              geom_scale=0.12,
                              command=callback,
                              textMayChange=1,
                              sortOrder=70,
                              extraArgs=[skillId])
        self.initialiseoptions(AmmoPanelButton)
        gui = loader.loadModel('models/gui/toplevel_gui')
        self.lockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
        if not Freebooter.getPaidStatus(
                base.localAvatar.doId
        ) and skillId > CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
            self.lock = DirectFrame(parent=self,
                                    relief=None,
                                    image=self.lockIcon,
                                    image_scale=0.14000000000000001,
                                    image_pos=(0.050000000000000003, 0,
                                               -0.025000000000000001),
                                    sortOrder=99)

        self.bind(DGG.ENTER, self.showDetails)
        self.bind(DGG.EXIT, self.hideDetails)
Esempio n. 36
0
 def __init__(self, npc, shopId, **kw):
     optiondefs = (('relief', None, None), ('framSize', (0, self.width, 0, self.height), None), ('sortOrder', 20, None))
     self.defineoptions(kw, optiondefs)
     DirectFrame.__init__(self, None, **None)
     self.initialiseoptions(BarberStoreGUI)
     self.pirate = None
     self.camIval = None
     self.buttons = []
     self.buttonIndex = 0
     self.itemAmount = 0
     self.currentPage = None
     self.confirmBox = None
     self.buttonsPerPage = 3
     self.displayRegionStates = { }
     self.numPages = 0
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.CoinImage = gui.find('**/treasure_w_coin*')
     self.ParchmentIcon = gui.find('**/main_gui_quest_scroll')
     self.barberIconsA = loader.loadModel('models/gui/char_gui')
     self.barberIconsB = loader.loadModel('models/textureCards/shopIcons')
     self.ShirtIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
     self.LockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
     self.backTabParent = self.attachNewNode('backTabs', sort = 0)
     self.panel = GuiPanel.GuiPanel(None, self.width, self.height, parent = self, showClose = False)
     self.setPos(0.0, 0, -0.75)
     self.balance = 0
     self.npc = npc
     self.rootTitle = PLocalizer.ShopBarber
     self.paid = Freebooter.getPaidStatus(localAvatar.getDoId())
     self.shopId = shopId
     if localAvatar.gameFSM.camIval is not None:
         if localAvatar.gameFSM.camIval.isPlaying():
             localAvatar.gameFSM.camIval.finish()
         
     
     self.initialCamPos = camera.getPos()
     self.initialCamHpr = camera.getHpr()
     self.initialPirateH = 0
     self.cartWidth = self.columnWidth - 0.10000000000000001
     self.cartHeight = self.height - 0.25
     self.cartFrame = DirectFrame(parent = self.panel, relief = None, frameSize = (0, self.cartWidth, 0, self.cartHeight))
     self.cartFrame.setPos(self.columnWidth + 0.025000000000000001, 0, 0.080000000000000002)
     self.categoryText = [
         [
             PLocalizer.Hat,
             PLocalizer.Hats],
         [
             PLocalizer.Shirt,
             PLocalizer.Shirts],
         [
             PLocalizer.Vest,
             PLocalizer.Vests],
         [
             PLocalizer.Coat,
             PLocalizer.Coats],
         [
             PLocalizer.Pants,
             PLocalizer.Pants],
         [
             PLocalizer.Belt,
             PLocalizer.Belts],
         [
             None,
             None],
         [
             PLocalizer.Shoe,
             PLocalizer.Shoes]]
     self.frontTabParent = self.panel.attachNewNode('frontTab', sort = 2)
     self.myGoldTitle = DirectFrame(parent = self.cartFrame, relief = None, text = PLocalizer.YourMoney, text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, pos = (-0.375, 0, 0.17499999999999999))
     self.myGold = DirectFrame(parent = self.cartFrame, relief = None, text = str(localAvatar.getMoney()), text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, image = self.CoinImage, image_scale = 0.14999999999999999, image_pos = (0.029999999999999999, 0, 0.014999999999999999), pos = (-0.059999999999999998, 0, 0.17499999999999999))
     self.closeButton = DialogButton.DialogButton(command = self.closePanel, parent = self.cartFrame, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG2, text_pos = (0.02, -(PiratesGuiGlobals.TextScaleLarge) * 0.25), text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, buttonStyle = DialogButton.DialogButton.NO)
     self.closeButton.setPos(0, 0, 0.0050000000000000001)
     tGui = loader.loadModel('models/gui/triangle')
     triangle = (tGui.find('**/triangle'), tGui.find('**/triangle_down'), tGui.find('**/triangle_over'))
     self.nextPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = 0.065000000000000002, pos = (0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.nextPage)
     self.prevPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = -0.065000000000000002, pos = (-0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.previousPage)
     self.pageNumber = DirectFrame(parent = self.cartFrame, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.0, 0.0), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0.089999999999999997))
     self.titleLabel = DirectLabel(parent = self, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG1, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge * 1.3, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.62, 0.0, 1.3300000000000001))
     self.titleLabel.setBin('gui-fixed', 1)
     self.createPirate()
     charGui = loader.loadModel('models/gui/char_gui')
     self.rotateSlider = DirectSlider(parent = base.a2dBottomLeft, relief = None, command = self.rotatePirate, image = charGui.find('**/chargui_slider_small'), image_scale = (2.1499999999999999, 2.1499999999999999, 1.5), thumb_relief = None, thumb_image = (charGui.find('**/chargui_slider_node'), charGui.find('**/chargui_slider_node_down'), charGui.find('**/chargui_slider_node_over')), pos = (0.80000000000000004, 0.0, 0.089999999999999997), text_align = TextNode.ACenter, text_scale = (0.10000000000000001, 0.10000000000000001), text_pos = (0.0, 0.10000000000000001), text_fg = PiratesGuiGlobals.TextFG1, scale = 0.42999999999999999, text = PLocalizer.RotateSlider, value = 0.5, sortOrder = -1)
     self.rotateSlider['extraArgs'] = [
         self.rotateSlider]
     self.rotateSliderOrigin = 0.5
     self.accept('mouse1', self._startMouseReadTask)
     self.accept('mouse1-up', self._stopMouseReadTask)
     self.clothWindows = []
     self.clothRenders = []
     self.clothHumans = []
     self.clothCameraNPs = []
     self.clothCameras = []
     self.createDisplayRegions()
     self.alertDialog = None
     self.accept('aspectRatioChanged', self.aspectRatioChange)
     self.accept('NonPayerPanelShown', self.hideDisplayRegions)
     self.accept('NonPayerPanelHidden', self.showDisplayRegions)
     self.accept('MainMenuShown', self.hideDisplayRegions)
     self.accept('MainMenuHidden', self.showDisplayRegions)
     self.accept('GUIShown', self.showDisplayRegions)
     self.accept('GUIHidden', self.hideDisplayRegions)
     localAvatar.guiMgr.chatPanel.show()
     localAvatar.guiMgr.chatPanel.startFadeTextIval()
     self.model = loader.loadModel('models/gui/gui_shop_tailor')
     self.model.reparentTo(self.panel)
     self.model.setBin('gui-fixed', 0)
     self.model.setPos(0.625, 0.0, 1.05)
     self.model.setScale(0.33700000000000002, 0.0, 0.32700000000000001)
     localAvatar.guiMgr.hideTrackedQuestInfo()
     self.initTabs()
     self.updateBalance()
     self.focusCamera()
Esempio n. 37
0
 def addPoint(self, skillId):
     if skillId == InventoryType.SailPowerRecharge:
         return
     inv = localAvatar.getInventory()
     frameSkillId = skillId
     skillId = WeaponGlobals.getLinkedSkillId(frameSkillId)
     if not skillId:
         skillId = frameSkillId
     if self.currentRep == InventoryType.CutlassRep and localAvatar.style.tutorial < PiratesGlobals.TUT_GOT_CUTLASS:
         if inv.getStackQuantity(InventoryType.CutlassSweep) < 2:
             if skillId != InventoryType.CutlassSweep:
                 return
         elif skillId == InventoryType.CutlassSweep:
             messenger.send('skillImprovementAttempted')
     unSpentId = self.getUnspent()
     unSp = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         unSp = self.localMods[unSpentId]
     if unSp < 1:
         return
     if inv.getStackLimit(skillId):
         curAmt = inv.getStackQuantity(skillId)
         if skillId in self.localMods:
             curAmt = self.localMods[skillId]
         if curAmt > 5:
             return
         else:
             curAmt += 1
     else:
         return
     self.__handleFreeDialog()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if curAmt > Freebooter.FreeSkillCap:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillMax,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
         playerExp = inv.getAccumulator(self.currentRep)
         categoryLevel, extra = ReputationGlobals.getLevelFromTotalReputation(
             self.currentRep, playerExp)
         alreadySpent = categoryLevel - 1 - unSp
         if alreadySpent > 5:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillLock,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
     if not base.config.GetBool('want-combo-skips', 0):
         comboSkills = [
             InventoryType.CutlassSlash, InventoryType.CutlassCleave,
             InventoryType.CutlassFlourish, InventoryType.CutlassStab,
             InventoryType.DaggerSwipe, InventoryType.DaggerGouge,
             InventoryType.DaggerEviscerate
         ]
         if skillId in comboSkills and inv.getStackQuantity(skillId -
                                                            1) <= 1:
             base.localAvatar.guiMgr.createWarning(
                 PLocalizer.ComboOrderWarn, PiratesGuiGlobals.TextFG6)
             return
     messenger.send('skillImprovementAttempted')
     localAvatar.spendSkillPoint(skillId)
     self.localMods[skillId] = curAmt
     self.localMods[unSpentId] = unSp - 1
     self.skillFrames[frameSkillId].skillRank = curAmt - 1
    def __init__(self, npc, shopId, **kw):
        optiondefs = (('relief', None, None), ('framSize', (0, self.width, 0, self.height), None), ('sortOrder', 20, None))
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, None)
        self.initialiseoptions(BarberStoreGUI)
        self.pirate = None
        self.camIval = None
        self.buttons = []
        self.buttonIndex = 0
        self.itemAmount = 0
        self.currentPage = None
        self.confirmBox = None
        self.buttonsPerPage = 3
        self.displayRegionStates = { }
        self.numPages = 0
        gui = loader.loadModel('models/gui/toplevel_gui')
        self.CoinImage = gui.find('**/treasure_w_coin*')
        self.ParchmentIcon = gui.find('**/main_gui_quest_scroll')
        self.barberIconsA = loader.loadModel('models/gui/char_gui')
        self.barberIconsB = loader.loadModel('models/textureCards/shopIcons')
        self.ShirtIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
        self.LockIcon = gui.find('**/pir_t_gui_gen_key_subscriber')
        self.backTabParent = self.attachNewNode('backTabs', sort = 0)
        self.panel = GuiPanel.GuiPanel(None, self.width, self.height, parent = self, showClose = False)
        self.setPos(0.0, 0, -0.75)
        self.balance = 0
        self.npc = npc
        self.rootTitle = PLocalizer.ShopBarber
        self.paid = Freebooter.getPaidStatus(localAvatar.getDoId())
        self.shopId = shopId
        if localAvatar.gameFSM.camIval is not None:
            if localAvatar.gameFSM.camIval.isPlaying():
                localAvatar.gameFSM.camIval.finish()


        self.initialCamPos = camera.getPos()
        self.initialCamHpr = camera.getHpr()
        self.initialPirateH = 0
        self.cartWidth = self.columnWidth - 0.10000000000000001
        self.cartHeight = self.height - 0.25
        self.cartFrame = DirectFrame(parent = self.panel, relief = None, frameSize = (0, self.cartWidth, 0, self.cartHeight))
        self.cartFrame.setPos(self.columnWidth + 0.025000000000000001, 0, 0.080000000000000002)
        self.categoryText = [
            [
                PLocalizer.Hat,
                PLocalizer.Hats],
            [
                PLocalizer.Shirt,
                PLocalizer.Shirts],
            [
                PLocalizer.Vest,
                PLocalizer.Vests],
            [
                PLocalizer.Coat,
                PLocalizer.Coats],
            [
                PLocalizer.Pants,
                PLocalizer.Pants],
            [
                PLocalizer.Belt,
                PLocalizer.Belts],
            [
                None,
                None],
            [
                PLocalizer.Shoe,
                PLocalizer.Shoes]]
        self.frontTabParent = self.panel.attachNewNode('frontTab', sort = 2)
        self.myGoldTitle = DirectFrame(parent = self.cartFrame, relief = None, text = PLocalizer.YourMoney, text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, pos = (-0.375, 0, 0.17499999999999999))
        self.myGold = DirectFrame(parent = self.cartFrame, relief = None, text = str(localAvatar.getMoney()), text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, image = self.CoinImage, image_scale = 0.14999999999999999, image_pos = (0.029999999999999999, 0, 0.014999999999999999), pos = (-0.059999999999999998, 0, 0.17499999999999999))
        self.closeButton = DialogButton.DialogButton(command = self.closePanel, parent = self.cartFrame, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG2, text_pos = (0.02, -(PiratesGuiGlobals.TextScaleLarge) * 0.25), text_scale = PiratesGuiGlobals.TextScaleLarge, text_shadow = PiratesGuiGlobals.TextShadow, buttonStyle = DialogButton.DialogButton.NO)
        self.closeButton.setPos(0, 0, 0.0050000000000000001)
        tGui = loader.loadModel('models/gui/triangle')
        triangle = (tGui.find('**/triangle'), tGui.find('**/triangle_down'), tGui.find('**/triangle_over'))
        self.nextPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = 0.065000000000000002, pos = (0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.nextPage)
        self.prevPageButton = DirectButton(parent = self.cartFrame, relief = None, state = DGG.DISABLED, image = triangle, image_scale = -0.065000000000000002, pos = (-0.17999999999999999, 0.0, 0.10000000000000001), rolloverSound = None, command = self.previousPage)
        self.pageNumber = DirectFrame(parent = self.cartFrame, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG2, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.0, 0.0), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0.089999999999999997))
        self.titleLabel = DirectLabel(parent = self, relief = None, text = '', text_fg = PiratesGuiGlobals.TextFG1, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge * 1.3, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.62, 0.0, 1.3300000000000001))
        self.titleLabel.setBin('gui-fixed', 1)
        self.createPirate()
        charGui = loader.loadModel('models/gui/char_gui')
        self.rotateSlider = DirectSlider(parent = base.a2dBottomLeft, relief = None, command = self.rotatePirate, image = charGui.find('**/chargui_slider_small'), image_scale = (2.1499999999999999, 2.1499999999999999, 1.5), thumb_relief = None, thumb_image = (charGui.find('**/chargui_slider_node'), charGui.find('**/chargui_slider_node_down'), charGui.find('**/chargui_slider_node_over')), pos = (0.80000000000000004, 0.0, 0.089999999999999997), text_align = TextNode.ACenter, text_scale = (0.10000000000000001, 0.10000000000000001), text_pos = (0.0, 0.10000000000000001), text_fg = PiratesGuiGlobals.TextFG1, scale = 0.42999999999999999, text = PLocalizer.RotateSlider, value = 0.5, sortOrder = -1)
        self.rotateSlider['extraArgs'] = [
            self.rotateSlider]
        self.rotateSliderOrigin = 0.5
        self.accept('mouse1', self._startMouseReadTask)
        self.accept('mouse1-up', self._stopMouseReadTask)
        self.clothWindows = []
        self.clothRenders = []
        self.clothHumans = []
        self.clothCameraNPs = []
        self.clothCameras = []
        self.createDisplayRegions()
        self.alertDialog = None
        self.accept('aspectRatioChanged', self.aspectRatioChange)
        self.accept('NonPayerPanelShown', self.hideDisplayRegions)
        self.accept('NonPayerPanelHidden', self.showDisplayRegions)
        self.accept('MainMenuShown', self.hideDisplayRegions)
        self.accept('MainMenuHidden', self.showDisplayRegions)
        self.accept('GUIShown', self.showDisplayRegions)
        self.accept('GUIHidden', self.hideDisplayRegions)
        localAvatar.guiMgr.chatPanel.show()
        localAvatar.guiMgr.chatPanel.startFadeTextIval()
        self.model = loader.loadModel('models/gui/gui_shop_tailor')
        self.model.reparentTo(self.panel)
        self.model.setBin('gui-fixed', 0)
        self.model.setPos(0.625, 0.0, 1.05)
        self.model.setScale(0.33700000000000002, 0.0, 0.32700000000000001)
        localAvatar.guiMgr.hideTrackedQuestInfo()
        self.initTabs()
        self.updateBalance()
        self.focusCamera()
Esempio n. 39
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) and self.isEmpty() or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

        inv = localAvatar.getInventory()
        if not inv:
            return None

        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
        border = self.SkillIcons.find('**/base')
        halfWidth = 0.29999999999999999
        halfHeight = 0.20000000000000001
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ

        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.029999999999999999
        runningVertPosition = 0.29999999999999999
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        subtypeText = PLocalizer.getItemSubtypeName(
            ItemGlobals.getSubtype(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        elif rarity == ItemGlobals.COMMON:
            titleColor = PiratesGuiGlobals.TextFG13
        elif rarity == ItemGlobals.RARE:
            titleColor = PiratesGuiGlobals.TextFG4
        elif rarity == ItemGlobals.FAMED:
            titleColor = PiratesGuiGlobals.TextFG5

        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x01slant\x01%s %s\x02' %
                                    (rarityText, subtypeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.050000000000000003
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        itemType = ItemGlobals.getType(itemId)
        itemSubtype = ItemGlobals.getSubtype(itemId)
        model = ItemGlobals.getModel(itemId)
        if model:
            self.realItem = loader.loadModel('models/inventory/' + model)
            if self.realItem:
                posHpr = ItemGlobals.getModelPosHpr(model)
                if posHpr:
                    self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                    self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
                elif itemSubtype == ItemGlobals.RAM:
                    self.realItem.setPos(-1.5, 1.5, -0.59999999999999998)
                    self.realItem.setHpr(70, 160, -90)
                else:
                    self.realItem.setPos(0.0, 1.5, -0.059999999999999998)
                    self.realItem.setHpr(0, 90, 0)
                self.realItem.reparentTo(self.portraitSceneGraph)

        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell and self.cell.container:
            itemCost = int(itemCost * self.cell.container.getItemPriceMult())

        goldLabel = DirectLabel(
            parent=self,
            relief=None,
            image=coinImage,
            image_scale=0.12,
            image_pos=Vec3(0.025000000000000001, 0, -0.02),
            text=str(itemCost),
            text_scale=subtitleScale,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(halfWidth - 0.050000000000000003, 0.0,
                 runningVertPosition + 0.080000000000000002),
            text_pos=(0.0, -textScale))
        labels.append(goldLabel)
        specialAttack = ItemGlobals.getSpecialAttack(itemId)
        if specialAttack:
            attackIcon = self.SkillIcons.find(
                '**/%s' % WeaponGlobals.getSkillIcon(specialAttack))
            specialAttackNameLabel = DirectLabel(
                parent=self,
                relief=None,
                image=border,
                image_scale=0.10000000000000001,
                geom=attackIcon,
                geom_scale=0.10000000000000001,
                image_pos=(-0.070000000000000007, 0.0, -0.050000000000000003),
                geom_pos=(-0.070000000000000007, 0.0, -0.050000000000000003),
                text=PLocalizer.getInventoryTypeName(specialAttack),
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_wordwrap=halfWidth * 2.0 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                text_fg=titleColor,
                text_font=PiratesGlobals.getInterfaceOutlineFont(),
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition),
                text_pos=(0.0, -textScale))
            specialAttackRankLabel = DirectLabel(
                parent=self,
                relief=None,
                text=PLocalizer.ItemRank %
                ItemGlobals.getSpecialAttackRank(itemId),
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.0 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ARight,
                pos=(halfWidth - textScale * 0.5, 0.0, runningVertPosition),
                text_pos=(0.0, -textScale))
            specialAttackType = WeaponGlobals.getSkillTrack(specialAttack)
            if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX:
                specialAttackTypeText = PLocalizer.BreakAttackSkill
            elif specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX:
                specialAttackTypeText = PLocalizer.DefenseSkill
            else:
                specialAttackTypeText = PLocalizer.WeaponSkill
            specialAttackTypeLabel = DirectLabel(
                parent=self,
                relief=None,
                text=specialAttackTypeText,
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_wordwrap=halfWidth * 2.7999999999999998 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition - PiratesGuiGlobals.TextScaleLarge),
                text_pos=(0.0, -textScale))
            specialAttackInfo = PLocalizer.SkillDescriptions.get(specialAttack)
            specialAttackDescriptionText = specialAttackInfo[1]
            specialAttackDescriptionLabel = DirectLabel(
                parent=self,
                relief=None,
                text=specialAttackDescriptionText,
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.7999999999999998 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition - specialAttackNameLabel.getHeight() +
                     specialAttackTypeLabel.getHeight() -
                     0.059999999999999998),
                text_pos=(0.0, -textScale))
            saHeight = specialAttackNameLabel.getHeight(
            ) + specialAttackTypeLabel.getHeight(
            ) + specialAttackDescriptionLabel.getHeight(
            ) - 0.040000000000000001
            runningVertPosition -= saHeight
            runningSize += saHeight
            labels.append(specialAttackNameLabel)
            labels.append(specialAttackRankLabel)
            labels.append(specialAttackTypeLabel)
            labels.append(specialAttackDescriptionLabel)

        attributes = ItemGlobals.getAttributes(itemId)
        for i in range(0, len(attributes)):
            attributeIcon = self.SkillIcons.find(
                '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))
            if not attributeIcon:
                attributeIcon = self.BuffIcons.find(
                    '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))

            attributeNameLabel = DirectLabel(
                parent=self,
                relief=None,
                image=border,
                image_scale=0.050000000000000003,
                geom=attributeIcon,
                geom_scale=0.050000000000000003,
                image_pos=(-0.070000000000000007, 0.0, -0.029999999999999999),
                geom_pos=(-0.070000000000000007, 0.0, -0.029999999999999999),
                text=PLocalizer.getItemAttributeName(attributes[i][0]),
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.0 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                text_fg=titleColor,
                text_font=PiratesGlobals.getInterfaceOutlineFont(),
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition),
                text_pos=(0.0, -textScale))
            attributeRankLabel = DirectLabel(
                parent=self,
                relief=None,
                text=PLocalizer.ItemRank % attributes[i][1],
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.0 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ARight,
                pos=(halfWidth - textScale * 0.5, 0.0, runningVertPosition),
                text_pos=(0.0, -textScale))
            if attributeNameLabel.getHeight() > 0.074999999999999997:
                attributeNameSpace = 0.080000000000000002
            else:
                attributeNameSpace = PiratesGuiGlobals.TextScaleLarge
            attributeDescriptionLabel = DirectLabel(
                parent=self,
                relief=None,
                text=PLocalizer.getItemAttributeDescription(attributes[i][0]),
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.7999999999999998 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition - attributeNameSpace),
                text_pos=(0.0, -textScale))
            aHeight = attributeNameLabel.getHeight(
            ) + attributeDescriptionLabel.getHeight()
            runningVertPosition -= aHeight + splitHeight
            runningSize += aHeight + splitHeight
            labels.append(attributeNameLabel)
            labels.append(attributeRankLabel)
            labels.append(attributeDescriptionLabel)

        skillBoosts = ItemGlobals.getSkillBoosts(itemId)
        for i in range(0, len(skillBoosts)):
            boostIcon = self.SkillIcons.find(
                '**/%s' % WeaponGlobals.getSkillIcon(skillBoosts[i][0]))
            boostNameLabel = DirectLabel(
                parent=self,
                relief=None,
                image=border,
                image_scale=0.050000000000000003,
                geom=boostIcon,
                geom_scale=0.050000000000000003,
                image_pos=(-0.070000000000000007, 0.0, -0.029999999999999999),
                geom_pos=(-0.070000000000000007, 0.0, -0.029999999999999999),
                text=PLocalizer.ItemBoost %
                PLocalizer.getInventoryTypeName(skillBoosts[i][0]),
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.0 *
                (0.90000000000000002 / titleScale),
                text_align=TextNode.ALeft,
                pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                     runningVertPosition),
                text_pos=(0.0, -textScale))
            boostRankLabel = DirectLabel(parent=self,
                                         relief=None,
                                         text='+%s' % str(skillBoosts[i][1]),
                                         text_scale=textScale,
                                         text_wordwrap=halfWidth * 2.0 *
                                         (0.90000000000000002 / titleScale),
                                         text_align=TextNode.ARight,
                                         pos=(halfWidth - textScale * 0.5, 0.0,
                                              runningVertPosition),
                                         text_pos=(0.0, -textScale))
            bHeight = boostNameLabel.getHeight()
            runningVertPosition -= bHeight + splitHeight
            runningSize += bHeight + splitHeight
            labels.append(boostNameLabel)
            labels.append(boostRankLabel)

        description = PLocalizer.getItemFlavorText(itemId)
        if description != '':
            descriptionLabel = DirectLabel(parent=self,
                                           relief=None,
                                           text=description,
                                           text_scale=textScale,
                                           text_wordwrap=halfWidth * 2.0 *
                                           (0.94999999999999996 / textScale),
                                           text_align=TextNode.ALeft,
                                           pos=(-halfWidth + textScale * 0.5,
                                                0.0, runningVertPosition),
                                           text_pos=(0.0, -textScale))
            dHeight = descriptionLabel.getHeight() + 0.02
            runningVertPosition -= dHeight
            runningSize += dHeight
            labels.append(descriptionLabel)

        weaponLevel = 0
        weaponRepId = WeaponGlobals.getRepId(itemId)
        weaponRep = inv.getReputation(weaponRepId)
        weaponReq = ItemGlobals.getWeaponRequirement(itemId)
        weaponText = None
        if weaponReq:
            weaponLevel = ReputationGlobals.getLevelFromTotalReputation(
                weaponRepId, weaponRep)[0]
            if weaponLevel < weaponReq:
                weaponColor = PiratesGuiGlobals.TextFG6
            else:
                weaponColor = (0.40000000000000002, 0.40000000000000002,
                               0.40000000000000002, 1.0)
            weaponText = PLocalizer.ItemLevelRequirement % (
                weaponReq, PLocalizer.getItemTypeName(itemType))
        else:
            trainingToken = EconomyGlobals.getItemTrainingReq(itemId)
            trainingAmt = inv.getItemQuantity(trainingToken)
            if trainingAmt == 0:
                weaponColor = PiratesGuiGlobals.TextFG6
                weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(
                    itemType)

        if weaponText:
            weaponReqLabel = DirectLabel(
                parent=self,
                relief=None,
                text=weaponText,
                text_scale=textScale,
                text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                text_fg=weaponColor,
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_align=TextNode.ACenter,
                pos=(0.0, 0.0, runningVertPosition),
                text_pos=(0.0, -textScale))
            wHeight = weaponReqLabel.getHeight()
            runningVertPosition -= wHeight
            runningSize += wHeight
            labels.append(weaponReqLabel)

        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.UnlimitedAccessRequirement,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=PiratesGuiGlobals.TextFG6,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)

        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.080000000000000002)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.080000000000000002)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.080000000000000002
        currentHeight = runningVertPosition
        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.080000000000000002)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.20000000000000001 >= heightMax:
                difference = heightMax - currentHeight
                placement += (0.16800000000000001 /
                              0.20000000000000001) * difference
                currentHeight += difference
            else:
                placement += 0.16800000000000001
                currentHeight += 0.20000000000000001
            middlePanel.setZ(-placement)
            i += 1
        bottomPanel = panels.attachNewNode('bottomPanel')
        detailGui.find('**/bottom_panel').copyTo(bottomPanel)
        bottomPanel.setScale(0.080000000000000002)
        bottomPanel.setZ(-placement)
        bottomPanel.reparentTo(self.helpFrame)
        colorPanel = panels.attachNewNode('colorPanel')
        detailGui.find('**/color').copyTo(colorPanel)
        colorPanel.setScale(0.080000000000000002)
        colorPanel.setColor(titleColor)
        colorPanel.reparentTo(self.helpFrame)
        lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
        detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
        lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002,
                                   0.070000000000000007)
        lineBreakTopPanel.setZ(0.0080000000000000002)
        lineBreakTopPanel.reparentTo(self.helpFrame)
        panels.flattenStrong()
        self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                       -(runningSize + vMargin), vMargin)
        totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
        for label in labels:
            label.reparentTo(self.helpFrame)

        if basePosX > 0.0:
            newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
        else:
            newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            (newPosX, newPosZ) = detailsPos

        self.helpFrame.setPos(newPosX, 0, newPosZ)
Esempio n. 40
0
 def addPoint(self, skillId):
     if skillId == InventoryType.SailPowerRecharge:
         return None
     
     inv = localAvatar.getInventory()
     frameSkillId = skillId
     skillId = WeaponGlobals.getLinkedSkillId(frameSkillId)
     if not skillId:
         skillId = frameSkillId
     
     if self.currentRep == InventoryType.CutlassRep and localAvatar.style.tutorial < PiratesGlobals.TUT_GOT_CUTLASS:
         if inv.getStackQuantity(InventoryType.CutlassSweep) < 2:
             if skillId != InventoryType.CutlassSweep:
                 return None
             
         elif skillId == InventoryType.CutlassSweep:
             messenger.send('skillImprovementAttempted')
         
     
     unSpentId = self.getUnspent()
     unSp = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         unSp = self.localMods[unSpentId]
     
     if unSp < 1:
         return None
     
     if inv.getStackLimit(skillId):
         curAmt = inv.getStackQuantity(skillId)
         if skillId in self.localMods:
             curAmt = self.localMods[skillId]
         
         if curAmt > 5:
             return None
         else:
             curAmt += 1
     else:
         return None
     self._SkillPage__handleFreeDialog()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if curAmt > Freebooter.FreeSkillCap:
             self.spentDialog = PDialog.PDialog(text = PLocalizer.FreebooterSkillMax, style = OTPDialog.CancelOnly, command = self._SkillPage__handleFreeDialog)
             return None
         
         playerExp = inv.getAccumulator(self.currentRep)
         (categoryLevel, extra) = ReputationGlobals.getLevelFromTotalReputation(self.currentRep, playerExp)
         alreadySpent = categoryLevel - 1 - unSp
         if alreadySpent > 5:
             self.spentDialog = PDialog.PDialog(text = PLocalizer.FreebooterSkillLock, style = OTPDialog.CancelOnly, command = self._SkillPage__handleFreeDialog)
             return None
         
     
     if not base.config.GetBool('want-combo-skips', 0):
         comboSkills = [
             InventoryType.CutlassSlash,
             InventoryType.CutlassCleave,
             InventoryType.CutlassFlourish,
             InventoryType.CutlassStab,
             InventoryType.DaggerSwipe,
             InventoryType.DaggerGouge,
             InventoryType.DaggerEviscerate]
         if skillId in comboSkills and inv.getStackQuantity(skillId - 1) <= 1:
             base.localAvatar.guiMgr.createWarning(PLocalizer.ComboOrderWarn, PiratesGuiGlobals.TextFG6)
             return None
         
     
     messenger.send('skillImprovementAttempted')
     localAvatar.spendSkillPoint(skillId)
     self.localMods[skillId] = curAmt
     self.localMods[unSpentId] = unSp - 1
     self.skillFrames[frameSkillId].skillRank = curAmt - 1
Esempio n. 41
0
    def enableStatsOV(self, shipOV):
        self.snapShot = ShipSnapshot(self,
                                     shipOV,
                                     self['siegeTeam'],
                                     pos=self['snapShotPos'])
        typeStr = ''
        if self['siegeTeam']:
            hp = shipOV.maxHp
            sp = shipOV.maxSp
        else:
            hp = shipOV.Hp
            sp = shipOV.Sp
        if hp <= 0:
            self.button['state'] = DGG.DISABLED
            self.button['text'] = PLocalizer.DeployShip
            stateStr = '\x01Ired\x01%s\x02' % PLocalizer.ShipSunk
            self['shipColorScale'] = VBase4(1, 0.40000000000000002,
                                            0.40000000000000002, 1)
            self.button['image3_color'] = VBase4(
                *PiratesGuiGlobals.ButtonColor3[2])
            self.button['geom3_color'] = VBase4(0.40000000000000002,
                                                0.40000000000000002,
                                                0.40000000000000002,
                                                0.40000000000000002)
            self.button['text3_color'] = VBase4(0.40000000000000002,
                                                0.40000000000000002,
                                                0.40000000000000002,
                                                0.40000000000000002)
            self.button['helpText'] = PLocalizer.ShipSunk
        elif len(shipOV.crew) >= shipOV.maxCrew:
            self.button['state'] = DGG.DISABLED
            self.button['text'] = PLocalizer.BoardShip
            self.button['helpText'] = PLocalizer.ShipFull
            stateStr = '\x01red\x01%s\x02' % (PLocalizer.ShipFull, )
            self['shipColorScale'] = VBase4(0.40000000000000002,
                                            0.40000000000000002,
                                            0.40000000000000002, 1)
        elif localAvatar.getActiveShipId(
        ) and shipOV.doId != localAvatar.getActiveShipId():
            self.button['state'] = DGG.DISABLED
            self.button['text'] = PLocalizer.DeployShip
            self.button['helpText'] = PLocalizer.OtherShipOut
            stateStr = '\x01Ired\x01%s\x02' % PLocalizer.OtherShipOut
            self['shipColorScale'] = VBase4(0.40000000000000002,
                                            0.40000000000000002,
                                            0.40000000000000002, 1)
        elif shipOV.state in 'Off':
            self.button['state'] = DGG.NORMAL
            self.button['text'] = PLocalizer.DeployShip
            stateStr = PLocalizer.ShipInBottle
            self.button['helpText'] = PLocalizer.ShipInBottle
        else:
            self.button['state'] = DGG.NORMAL
            self.button['text'] = PLocalizer.BoardShip
            stateStr = PLocalizer.ShipAtSea
            self.button['helpText'] = PLocalizer.ShipAtSea
        if not Freebooter.getPaidStatus(base.localAvatar.getDoId(
        )) and shipOV.shipClass not in ShipGlobals.UNPAID_SHIPS:
            self.button['command'] = base.localAvatar.guiMgr.showNonPayer
            self.button['extraArgs'] = ['Restricted_ShipFrame_Deploy', 3]
            self.button['text'] = PLocalizer.Locked
            subgui = loader.loadModel('models/gui/toplevel_gui')
            if subgui:
                self.button['geom'] = subgui.find(
                    '**/pir_t_gui_gen_key_subscriber')
                self.button['geom_scale'] = 0.14999999999999999
                self.button['geom_color'] = Vec4(0.69999999999999996,
                                                 0.69999999999999996,
                                                 0.69999999999999996, 1.0)
                subgui.removeNode()

        if typeStr:
            self.typeLabel['text'] = '\x01smallCaps\x01(%s)\x02' % typeStr
Esempio n. 42
0
 def __init__(self, rep, weaponMode):
     self.rep = rep
     self.weaponMode = weaponMode
     localAvatar.cr.targetMgr.reticle.hide()
     if self.weaponMode in (WeaponGlobals.MELEE, WeaponGlobals.COMBAT, WeaponGlobals.THROWING):
         target = base.cr.targetMgr.takeAim(localAvatar)
         if target:
             localAvatar.guiMgr.combatTray.beginAimAssist(target)
         
     
     base.win.movePointer(0, base.win.getXSize() / 2, base.win.getYSize() / 2)
     localAvatar.guiMgr.setSeaChestAllowed(False)
     self.radial = { }
     self.rframe = { }
     self.ammoAmt = { }
     self.rstatus = { }
     self.rstatus[0] = 0
     self.rframe[0] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing.reparentTo(aspect2d)
     skillRing.setPos(0.01, 0, 0.01)
     if not self.SkillIcons:
         self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
         icons = loader.loadModel('models/gui/gui_icons_weapon')
         icons.reparentTo(self.SkillIcons)
     
     if self.rep == InventoryType.DollRep and localAvatar.hasStickyTargets():
         asset = getSkillIconName(self.rep, 1)
     else:
         asset = getSkillIconName(self.rep, 0)
     self.radial[0] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_scale = ImageScale(self.rep), image_pos = (0.059999999999999998, 0, 0.059999999999999998), pos = (-0.050000000000000003, 0, -0.050000000000000003), sortOrder = 10)
     self.radial[0].setTransparency(1)
     origMap = ActiveSkills(self.rep, 2)
     self.radialSkillMap = Freebooter.pruneFreebooterSkills(origMap)
     self.numberOfItems = len(self.radialSkillMap)
     for i in range(self.numberOfItems):
         (x, y) = InnerRingOffset(i + 1)
         self.rstatus[i + 1] = 0
         self.rframe[i + 1] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing.reparentTo(aspect2d)
         skillRing.setPos(0.01 + x, 0, 0.01 + y)
         asset = getSkillIconName(self.radialSkillMap[i], 0)
         self.radial[i + 1] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_pos = (0.059999999999999998, 0, 0.059999999999999998), image_scale = ImageScale(self.rep), sortOrder = 100, pos = (-0.050000000000000003 + x, 0, -0.050000000000000003 + y))
         self.radial[i + 1].setTransparency(1)
         if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE):
             inv = localAvatar.getInventory()
             skillId = self.radialSkillMap[i]
             maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId)
             if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId):
                 amtstr = '++'
             else:
                 ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                 ammoAmt = inv.getStackQuantity(ammoInvId)
                 ammoMax = inv.getStackLimit(ammoInvId)
                 amtstr = '%d' % ammoAmt
             self.ammoAmt[i + 1] = DirectLabel(parent = aspect2d, relief = None, text = amtstr, text_align = TextNode.ACenter, text_scale = 0.029999999999999999, text_fg = (0.69999999999999996, 1.0, 1.0, 1), text_font = PiratesGlobals.getPirateBoldOutlineFont(), pos = (x + 0.059999999999999998, 0, y + 0.040000000000000001), textMayChange = 1)
             continue
     
     self.mouseBasePosX = base.win.getXSize() / 2
     self.mouseBasePosY = base.win.getYSize() / 2
     self.radialHelp = DirectLabel(parent = aspect2d, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_fg = (0.94999999999999996, 1.0, 1.0, 1), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0), textMayChange = 1)
     self.radialHelp.hide()
     self.radial[0].show()
     self.rframe[0].show()
     self.hiLiteItem = 0
     taskMgr.add(self.radialMenuHeartBeat, 'radialMenuHeartBeat', priority = 40)
     messenger.send('openedSpecialMenu')
    def hasQuestOffers(self):
        AvailableQuests = []
        inventory = localAvatar.getInventory()
        prereqExcludes = base.config.GetString('exclude-prereq-quests', '')
        for (questId, questDNA) in QuestDB.QuestDict.items():
            if len(prereqExcludes):
                if questId in prereqExcludes:
                    continue


            prereqs = questDNA.getPrereqs()
            passed = True
            for prereq in prereqs:
                if not prereq.giverCanGive(self.getUniqueId()):
                    passed = False
                    break

                if not prereq.avIsReady(localAvatar):
                    passed = False
                    break

                if questDNA.minLevel > localAvatar.level:
                    passed = False
                    break

                if not base.cr.questDependency.checkDependency(questId, localAvatar.getQuestLadderHistory(), 1):
                    passed = False
                    break

                boolWeapLvlCheck = (questDNA.weapLvlType != None) & (questDNA.minWeapLevel > 0)
                if boolWeapLvlCheck & (questDNA.minWeapLevel > getLevelFromTotalReputation(questDNA.weapLvlType, inventory.getReputation(questDNA.weapLvlType))[0]):
                    passed = False
                    break

                if questDNA.getVelvetRoped() and not Freebooter.getPaidStatus(localAvatar.getDoId()):
                    passed = False
                    break

                if questDNA.getAcquireOnce():
                    history = localAvatar.getQuestLadderHistory()
                    questLadderId = base.cr.questDynMap.findQuestLadderInt(questId)
                    containsLadderId = history.count(questLadderId)
                    if containsLadderId:
                        passed = False
                        break


                if questDNA.getHoliday() is not None:
                    holidayId = questDNA.getHoliday()
                    if base.cr.newsManager and not base.cr.newsManager.getHoliday(holidayId):
                        passed = False
                        break

                not base.cr.newsManager.getHoliday(holidayId)

            if prereqs and passed:
                AvailableQuests.append(questDNA)
                continue

        if len(AvailableQuests):
            inventory = localAvatar.getInventory()
            if inventory:
                toRemove = []
                questList = inventory.getQuestList()
                for questDNA in AvailableQuests:
                    questId = questDNA.getQuestId()
                    found = False
                    for quest in questList:
                        if questId == quest.getQuestId() or localAvatar.questStatus.hasLadderQuestId(questId):
                            found = True
                            continue

                    if found:
                        toRemove.append(questDNA)
                        continue

                for questDNA in toRemove:
                    AvailableQuests.remove(questDNA)



        for quest in localAvatar.getQuests():
            if quest and quest.getTimeLimit() and quest.canBeReturnedTo(self.getQuestGiverId()):
                return True
                continue

        return len(AvailableQuests) > 0
 def refresh(self):
     inv = localAvatar.getInventory()
     origRank = self.rank
     if inv:
         invType = TitleGlobals.getInventoryType(self.titleId)
         if self.titleId == TitleGlobals.ShipPVPTitle:
             self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamySea)
         elif self.titleId == TitleGlobals.LandPVPTitle:
             self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamyLand)
         elif invType:
             self.expPoints = inv.getStackQuantity(invType)
         else:
             self.expPoints = 0
             if self.titleId == TitleGlobals.FounderTitle and localAvatar.getFounder():
                 self.expPoints = 1
             
         self.rank = TitleGlobals.getRank(self.titleId, self.expPoints)
         self.maxRank = TitleGlobals.getMaxRank(self.titleId)
         self.expTarget = TitleGlobals.getBreakpoints(self.titleId)[min(self.rank + 1, self.maxRank)]
         self.expBase = TitleGlobals.getBreakpoints(self.titleId)[self.rank]
     
     if self.titleNameFrame:
         self.titleNameFrame['text'] = TitleGlobals.getTitleRankName(self.titleId, self.expPoints)
     
     if self.expMeter:
         value = 0
         if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
             value = int((self.expPoints - self.expBase) * 100 / (self.expTarget - self.expBase))
         
         self.expMeter['value'] = value
     
     if self.expMeterText:
         if self.rank >= self.maxRank:
             self.expBase = 0
             self.expTarget = 0
         
         text = '0 / 0'
         if self.rank < self.maxRank and self.expTarget - self.expBase > 0:
             text = '%s / %s' % (self.expPoints - self.expBase, self.expTarget - self.expBase)
         
         self.expMeterText['text'] = text
     
     if self.iconFrame:
         icName = TitleGlobals.getIconName(self.titleId, self.rank)
         if icName:
             img = self.iconModel.find('**/' + icName)
         else:
             img = None
         self.iconFrame['image'] = img
         imgScale = TitleGlobals.getScale(self.titleId)
         self.iconFrame['image_scale'] = (0.065000000000000002 * imgScale, 1, 0.065000000000000002 * imgScale)
     
     titleOnOff = [
         PLocalizer.TitleOff,
         PLocalizer.TitleOn]
     if self.rank != origRank:
         if self.landActive:
             self.titlesPage.setLandActive(self.panelIndex, self.landActive)
         
         if self.seaActive:
             self.titlesPage.setSeaActive(self.panelIndex, self.seaActive)
         
     
     if self.rank == 0 or not Freebooter.getPaidStatus(localAvatar.doId):
         self.landButton.hide()
         self.seaButton.hide()
     else:
         self.landButton.show()
         self.seaButton.show()
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        halfWidth = 0.29999999999999999
        halfHeight = 0.20000000000000001
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ

        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.029999999999999999
        runningVertPosition = 0.29999999999999999
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        typeText = ClothingGlobals.getClothingTypeName(
            ItemGlobals.getType(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        elif rarity == ItemGlobals.COMMON:
            titleColor = PiratesGuiGlobals.TextFG13
        elif rarity == ItemGlobals.RARE:
            titleColor = PiratesGuiGlobals.TextFG4
        elif rarity == ItemGlobals.FAMED:
            titleColor = PiratesGuiGlobals.TextFG5

        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x001slant\x001%s %s\x002' %
                                    (rarityText, typeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.050000000000000003
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        clothingType = ItemGlobals.getType(itemId)
        if localAvatar.style.getGender() == 'm':
            maleModelId = ItemGlobals.getMaleModelId(itemId)
            if maleModelId != -1:
                modelId = maleModelId
                texId = ItemGlobals.getMaleTextureId(itemId)
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'm'
            else:
                modelId = ItemGlobals.getFemaleModelId(itemId)
                texId = ItemGlobals.getFemaleTextureId(itemId)
                dna = HumanDNA.HumanDNA('f')
                gender = 'f'
        else:
            femaleModelId = ItemGlobals.getFemaleModelId(itemId)
            if femaleModelId != -1:
                modelId = femaleModelId
                texId = ItemGlobals.getFemaleTextureId(itemId)
                dna = HumanDNA.HumanDNA(localAvatar.style.gender)
                dna.copy(localAvatar.style)
                gender = 'f'
            else:
                modelId = ItemGlobals.getMaleModelId(itemId)
                texId = ItemGlobals.getMaleTextureId(itemId)
                dna = HumanDNA.HumanDNA('m')
                gender = 'm'
        bodyShape = localAvatar.style.getBodyShape()
        bodyHeight = localAvatar.style.getBodyHeight()
        bodyOffset = 0.5
        headOffset = 0
        topOffset = 0
        pantOffset = 0
        beltOffset = 0
        shoeOffset = 0
        if bodyShape == 0:
            bodyOffset = 1
            headOffset = 0.69999999999999996
            topOffset = 0.69999999999999996
            pantOffset = 0.20000000000000001
            beltOffset = 0.5
        elif bodyShape == 1:
            bodyOffset = 0
            if gender == 'm':
                headOffset = -0.10000000000000001
                beltOffset = 0.10000000000000001
                shoeOffset = 0.10000000000000001
            elif gender == 'f':
                headOffset = 0.59999999999999998
                topOffset = 0.40000000000000002
                beltOffset = 0.40000000000000002
                shoeOffset = 0.10000000000000001

        elif bodyShape == 2:
            bodyOffset = 0.5
        elif bodyShape == 3:
            bodyOffset = 1
            if gender == 'm':
                topOffset = 0.10000000000000001
                beltOffset = 0.10000000000000001
            elif gender == 'f':
                headOffset = -0.40000000000000002
                topOffset = -0.10000000000000001
                beltOffset = -0.10000000000000001
                pantOffset = -0.10000000000000001

        elif bodyShape == 4:
            bodyOffset = 0.5
            if gender == 'm':
                headOffset = -0.20000000000000001
                topOffset = -0.29999999999999999
            elif gender == 'f':
                headOffset = 0.10000000000000001
                beltOffset = 0.10000000000000001

        elif bodyShape == 5:
            bodyOffset = 0.5
        elif bodyShape == 6:
            bodyOffset = 0.5
            if gender == 'f':
                headOffset = 0.40000000000000002
                topOffset = 0.40000000000000002
                beltOffset = 0.29999999999999999

        elif bodyShape == 7:
            bodyOffset = 0.5
        elif bodyShape == 8:
            bodyOffset = 0.5
            headOffset = -0.20000000000000001
            topOffset = -0.20000000000000001
        elif bodyShape == 9:
            bodyOffset = 0.5
            headOffset = -0.20000000000000001
            topOffset = -0.20000000000000001

        m = Mat4(Mat4.identMat())
        topColor = localAvatar.style.getClothesBotColor()
        botColor = localAvatar.style.getClothesTopColor()
        hatColor = localAvatar.style.getHatColor()
        (shirtIdx, shirtTex) = localAvatar.style.getClothesShirt()
        (hatIdx, hatTex) = localAvatar.style.getClothesHat()
        (coatIdx, coatTex) = localAvatar.style.getClothesCoat()
        (beltIdx, beltTex) = localAvatar.style.getClothesBelt()
        (shoeIdx, shoeTex) = localAvatar.style.getClothesShoe()
        (vestIdx, vestTex) = localAvatar.style.getClothesVest()
        (pantIdx, pantTex) = localAvatar.style.getClothesPant()
        dna.setClothesBotColor(topColor[0], topColor[1], topColor[2])
        dna.setClothesTopColor(botColor[0], botColor[1], botColor[2])
        dna.setHatColor(hatColor)
        dna.setClothesShirt(shirtIdx, shirtTex)
        dna.setClothesHat(hatIdx, hatTex)
        dna.setClothesBelt(beltIdx, beltTex)
        dna.setClothesPant(pantIdx, pantTex)
        dna.setClothesShoe(shoeIdx, shoeTex)
        if clothingType == ClothingGlobals.SHIRT:
            dna.setClothesVest(0)
            dna.setClothesCoat(0)
        elif clothingType == ClothingGlobals.VEST:
            dna.setClothesCoat(0)
        elif clothingType == ClothingGlobals.BELT:
            dna.setClothesCoat(0)
            dna.setClothesVest(0)
        else:
            dna.setClothesVest(vestIdx, vestTex)
            dna.setClothesCoat(coatIdx, coatTex)
        dna.setClothesByType(ClothingGlobals.CLOTHING_STRING[clothingType],
                             modelId, texId, self.itemTuple[3])
        self.displayHuman.setDNAString(dna)
        self.displayHuman.generateHuman(gender, self.masterHuman)
        self.displayHuman.stopBlink()
        self.displayHuman.pose('idle', 1)
        lodNode = self.displayHuman.find('**/+LODNode').node()
        lodNode.forceSwitch(lodNode.getHighestSwitch())
        if clothingType == ClothingGlobals.HAT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_head01').getNetTransform(m)
            headHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = (-headHeight -
                       0.40000000000000002) + headOffset - bodyHeight * 1.0
            offsetY = 2.0 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.SHIRT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 3.25 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.VEST:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 3.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.COAT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_spine02').getNetTransform(m)
            spine2Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine2Height + topOffset - bodyHeight * 1.3999999999999999
            offsetY = 4.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.PANT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_right_knee').getNetTransform(m)
            kneeHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -kneeHeight + pantOffset - 0.5 - bodyHeight * 0.29999999999999999
            offsetY = 4.5 + bodyOffset
            offsetH = 200
        elif clothingType == ClothingGlobals.BELT:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_hips').getNetTransform(m)
            hipHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -hipHeight + beltOffset - bodyHeight * 0.5
            offsetY = 1.7 + bodyOffset
            offsetH = 180
        elif clothingType == ClothingGlobals.SHOE:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint(
                'def_right_ankle').getNetTransform(m)
            ankleHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -ankleHeight + shoeOffset - 0.14999999999999999 - bodyHeight * -0.10000000000000001
            offsetY = 3.25 + bodyOffset
            offsetH = 200
        else:
            offsetZ = 0
            offsetY = 0
            offsetH = 0
        offsetX = 0
        self.displayHuman.setY(offsetY)
        self.displayHuman.setZ(offsetZ)
        self.displayHuman.setX(offsetX)
        self.displayHuman.setH(offsetH)
        self.displayHuman.reparentTo(self.portraitSceneGraph)
        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        if self.showResaleValue:
            value = int(
                ItemGlobals.getGoldCost(itemId) *
                ItemGlobals.GOLD_SALE_MULTIPLIER)
        else:
            value = ItemGlobals.getGoldCost(itemId)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell and self.cell.container:
            itemCost = int(itemCost * self.cell.container.getItemPriceMult())

        goldLabel = DirectLabel(
            parent=self,
            relief=None,
            image=coinImage,
            image_scale=0.12,
            image_pos=Vec3(0.025000000000000001, 0, -0.02),
            text=str(itemCost),
            text_scale=subtitleScale,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(halfWidth - 0.050000000000000003, 0.0,
                 runningVertPosition + 0.080000000000000002),
            text_pos=(0.0, -textScale))
        labels.append(goldLabel)
        descriptionLabel = DirectLabel(
            parent=self,
            relief=None,
            text=PLocalizer.getItemFlavorText(itemId),
            text_scale=textScale,
            text_wordwrap=halfWidth * 2.0 * (0.94999999999999996 / textScale),
            text_fg=PiratesGuiGlobals.TextFG0,
            text_align=TextNode.ALeft,
            pos=(-halfWidth + textScale * 0.5, 0.0, runningVertPosition),
            text_pos=(0.0, -textScale))
        dHeight = descriptionLabel.getHeight() + 0.02
        runningVertPosition -= dHeight
        runningSize += dHeight
        labels.append(descriptionLabel)
        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.UnlimitedAccessRequirement,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                    text_fg=PiratesGuiGlobals.TextFG6,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    text_align=TextNode.ACenter,
                    pos=(0.0, 0.0, runningVertPosition),
                    text_pos=(0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)

        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.080000000000000002)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.080000000000000002)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.080000000000000002
        currentHeight = runningVertPosition
        if detailsHeight:
            currentHeight = -detailsHeight

        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.080000000000000002)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.20000000000000001 >= heightMax:
                difference = heightMax - currentHeight
                placement += (0.16800000000000001 /
                              0.20000000000000001) * difference
                currentHeight += difference
            else:
                placement += 0.16800000000000001
                currentHeight += 0.20000000000000001
            middlePanel.setZ(-placement)
            i += 1
        bottomPanel = panels.attachNewNode('bottomPanel')
        detailGui.find('**/bottom_panel').copyTo(bottomPanel)
        bottomPanel.setScale(0.080000000000000002)
        bottomPanel.setZ(-placement)
        bottomPanel.reparentTo(self.helpFrame)
        colorPanel = self.helpFrame.attachNewNode('colorPanel')
        detailGui.find('**/color').copyTo(colorPanel)
        colorPanel.setScale(0.080000000000000002)
        colorPanel.setColor(titleColor)
        colorPanel.reparentTo(self.helpFrame)
        lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
        detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
        lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002,
                                   0.070000000000000007)
        lineBreakTopPanel.setZ(0.0080000000000000002)
        lineBreakTopPanel.reparentTo(self.helpFrame)
        panels.flattenStrong()
        self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                       -(runningSize + vMargin), vMargin)
        totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
        for label in labels:
            label.reparentTo(self.helpFrame)

        if basePosX > 0.0:
            newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
        else:
            newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            (newPosX, newPosZ) = detailsPos

        self.helpFrame.setPos(newPosX, 0, newPosZ)
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem or self.manager.locked or cell.isEmpty(
        ) or self.isEmpty() or not self.itemTuple:
            self.notify.debug(' early exit')
            return
        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
        border = self.SkillIcons.find('**/base')
        halfWidth = 0.3
        halfHeight = 0.2
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ
        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.03
        runningVertPosition = 0.3
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        subtypeText = PLocalizer.getItemSubtypeName(
            ItemGlobals.getSubtype(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
        else:
            if rarity == ItemGlobals.COMMON:
                titleColor = PiratesGuiGlobals.TextFG13
            else:
                if rarity == ItemGlobals.RARE:
                    titleColor = PiratesGuiGlobals.TextFG4
                else:
                    if rarity == ItemGlobals.FAMED:
                        titleColor = PiratesGuiGlobals.TextFG5
        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.07
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x01slant\x01%s %s\x02' %
                                    (rarityText, subtypeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.05
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        itemType = ItemGlobals.getType(itemId)
        itemSubtype = ItemGlobals.getSubtype(itemId)
        model = ItemGlobals.getModel(itemId)
        skillIcons = loader.loadModel('models/textureCards/skillIcons')
        if itemSubtype == ItemGlobals.POTION_BUFF:
            self.iconLabel = DirectLabel(
                parent=self.portraitSceneGraph,
                relief=None,
                image=skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)),
                pos=(0.0, 2.5, 0.0))
        else:
            if model:
                self.realItem = loader.loadModel('models/inventory/' + model,
                                                 okMissing=True)
                if not self.realItem:
                    self.realItem = loader.loadModel('models/handheld/' +
                                                     model)
                if self.realItem:
                    posHpr = ItemGlobals.getModelPosHpr(model)
                    if posHpr:
                        self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                        self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
                    else:
                        self.realItem.setPos(0.0, 2.5, -0.4)
                        self.realItem.setHpr(45, 0, 0)
                    self.realItem.reparentTo(self.portraitSceneGraph)
        iHeight = 0.18
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.06)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell:
            if self.cell.container:
                itemCost = int(itemCost *
                               self.cell.container.getItemPriceMult())
            goldLabel = DirectLabel(parent=self,
                                    relief=None,
                                    image=coinImage,
                                    image_scale=0.12,
                                    image_pos=Vec3(0.025, 0, -0.02),
                                    text=str(itemCost),
                                    text_scale=subtitleScale,
                                    text_align=TextNode.ARight,
                                    text_fg=PiratesGuiGlobals.TextFG1,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    pos=(halfWidth - 0.05, 0.0,
                                         runningVertPosition + 0.08),
                                    text_pos=(0.0, -textScale))
            labels.append(goldLabel)
            if ItemGlobals.getSubtype(itemId) == 30:
                duration = PotionGlobals.getPotionBuffDuration(
                    WeaponGlobals.getSkillEffectFlag(
                        ItemGlobals.getUseSkill(itemId)))
                if duration >= 3600:
                    duration = duration / 3600
                    if duration == 1:
                        units = PLocalizer.Hour
                    else:
                        units = PLocalizer.Hours
                else:
                    if duration >= 60:
                        duration = duration / 60
                        if duration == 1:
                            units = PLocalizer.Minute
                        else:
                            units = PLocalizer.Minutes
                    else:
                        units = PLocalizer.Seconds
                potency = PotionGlobals.getPotionPotency(
                    WeaponGlobals.getSkillEffectFlag(
                        ItemGlobals.getUseSkill(itemId)))
                data = {
                    'pot': int(potency * 100),
                    'dur': int(duration),
                    'unit': units
                }
                description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(
                    itemId)].safe_substitute(data)
            else:
                description = PLocalizer.getItemFlavorText(itemId)
            if description != '':
                descriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=description,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.95 / textScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                dHeight = descriptionLabel.getHeight() + 0.02
                runningVertPosition -= dHeight
                runningSize += dHeight
                labels.append(descriptionLabel)
            if not Freebooter.getPaidStatus(localAvatar.getDoId()):
                if rarity != ItemGlobals.CRUDE:
                    unlimitedLabel = DirectLabel(
                        parent=self,
                        relief=None,
                        text=PLocalizer.UnlimitedAccessRequirement,
                        text_scale=textScale,
                        text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale),
                        text_fg=PiratesGuiGlobals.TextFG6,
                        text_shadow=PiratesGuiGlobals.TextShadow,
                        text_align=TextNode.ACenter,
                        pos=(0.0, 0.0, runningVertPosition),
                        text_pos=(0.0, -textScale))
                    uHeight = unlimitedLabel.getHeight()
                    runningVertPosition -= uHeight
                    runningSize += uHeight
                    labels.append(unlimitedLabel)
            runningVertPosition -= 0.02
            runningSize += 0.02
            useLabel = DirectLabel(parent=self,
                                   relief=None,
                                   text=PLocalizer.RightClickPotion,
                                   text_scale=textScale,
                                   text_wordwrap=halfWidth * 2.0 *
                                   (1.5 / titleScale),
                                   text_fg=PiratesGuiGlobals.TextFG6,
                                   text_shadow=PiratesGuiGlobals.TextShadow,
                                   text_align=TextNode.ACenter,
                                   pos=(0.0, 0.0, runningVertPosition),
                                   text_pos=(0.0, -textScale))
            uHeight = useLabel.getHeight()
            runningVertPosition -= uHeight
            runningSize += uHeight
            labels.append(useLabel)
            runningVertPosition -= 0.02
            runningSize += 0.02
            panels = self.helpFrame.attachNewNode('panels')
            topPanel = panels.attachNewNode('middlePanel')
            detailGui.find('**/top_panel').copyTo(topPanel)
            topPanel.setScale(0.08)
            topPanel.reparentTo(self.helpFrame)
            middlePanel = panels.attachNewNode('middlePanel')
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.08)
            middlePanel.reparentTo(self.helpFrame)
            placement = 0
            i = 0
            heightMax = -0.08
            currentHeight = runningVertPosition
            if detailsHeight:
                currentHeight = -detailsHeight
            while currentHeight < heightMax:
                middlePanel = panels.attachNewNode('middlePanel%s' % 1)
                detailGui.find('**/middle_panel').copyTo(middlePanel)
                middlePanel.setScale(0.08)
                middlePanel.reparentTo(self.helpFrame)
                if currentHeight + 0.2 >= heightMax:
                    difference = heightMax - currentHeight
                    placement += 0.168 / 0.2 * difference
                    currentHeight += difference
                else:
                    placement += 0.168
                    currentHeight += 0.2
                middlePanel.setZ(-placement)
                i += 1

            bottomPanel = panels.attachNewNode('bottomPanel')
            detailGui.find('**/bottom_panel').copyTo(bottomPanel)
            bottomPanel.setScale(0.08)
            bottomPanel.setZ(-placement)
            bottomPanel.reparentTo(self.helpFrame)
            colorPanel = panels.attachNewNode('colorPanel')
            detailGui.find('**/color').copyTo(colorPanel)
            colorPanel.setScale(0.08)
            colorPanel.setColor(titleColor)
            colorPanel.reparentTo(self.helpFrame)
            lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
            detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
            lineBreakTopPanel.setScale(0.08, 0.08, 0.07)
            lineBreakTopPanel.setZ(0.008)
            lineBreakTopPanel.reparentTo(self.helpFrame)
            panels.flattenStrong()
            self.helpFrame['frameSize'] = (-halfWidth, halfWidth,
                                           -(runningSize + vMargin), vMargin)
            totalHeight = self.helpFrame.getHeight() - 0.1
            for label in labels:
                label.reparentTo(self.helpFrame)

            if basePosX > 0.0:
                newPosX = basePosX - (halfWidth + cellSizeX * 0.45)
            else:
                newPosX = basePosX + (halfWidth + cellSizeX * 0.45)
            newPosZ = basePosZ > 0.0 and basePosZ + cellSizeZ * 0.45
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
 def determineButtonState(self):
     self.guildName = None
     self.guildReal = None
     self.guildRank = None
     self.guildId = base.localAvatar.guildId
     if not self.setupFlag:
         self.setupButtons()
     
     if self.guildId:
         self.guildName = base.localAvatar.getGuildName()
         self.guildReal = self.guildName
         self.guildRank = base.localAvatar.getGuildRank()
         if self.guildName == '0' or self.guildName == '':
             self.guildName = PLocalizer.GuildDefaultName % self.guildId
         
         if hasattr(base, 'localAvatar'):
             inv = base.localAvatar.getInventory()
             if inv and not inv.getStackQuantity(InventoryType.NewGuild):
                 base.localAvatar.sendRequestContext(InventoryType.NewGuild)
             
         
     
     if self.nameLabel and self.guildName and self.guildName != PLocalizer.GuildNoGuild:
         if self.guildName != '0' or self.guildName != '':
             self.nameLabel.show()
             self.nameLabel['text'] = self.guildName
         elif self.nameLabel:
             self.nameLabel.hide()
         
     rank = base.localAvatar.getGuildRank()
     if rank == 1:
         ranktxt = PLocalizer.GuildRankMember
     elif rank == 2:
         ranktxt = PLocalizer.GuildRankSubLead
     elif rank == 3:
         ranktxt = PLocalizer.GuildRankLeader
     elif rank == 4:
         ranktxt = PLocalizer.GuildRankInviter
     else:
         ranktxt = None
     if self.rankLabel and rank and ranktxt:
         self.rankLabel['text'] = ranktxt
         self.rankLabel.show()
     elif self.rankLabel:
         ranktxt = PLocalizer.Loading
         self.rankLabel.hide()
     
     if self.memberButton:
         self.memberButton['state'] = DGG.DISABLED
     
     self.renameButton['state'] = DGG.DISABLED
     self.createButton['state'] = DGG.DISABLED
     self.leaveButton['state'] = DGG.DISABLED
     self.inviteButton['state'] = DGG.DISABLED
     self.redeemInvite['state'] = DGG.NORMAL
     self.codeInviteOptions['state'] = DGG.DISABLED
     if self.guildRank > 2:
         if (self.guildReal == '0' or self.guildReal == '') and not (self.recentlySentName):
             self.renameButton['state'] = DGG.NORMAL
             self.redeemInvite['state'] = DGG.DISABLED
         
     if self.guildRank > 1:
         self.inviteButton['state'] = DGG.NORMAL
         self.redeemInvite['state'] = DGG.DISABLED
         self.codeInviteOptions['state'] = DGG.NORMAL
     
     if self.guildRank > 0:
         self.leaveButton['state'] = DGG.NORMAL
         self.memberButton['state'] = DGG.NORMAL
         self.redeemInvite['state'] = DGG.DISABLED
     else:
         self.createButton['state'] = DGG.NORMAL
     if Freebooter.FreeGuildRestrict:
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if self.createButton:
                 self.createButton['state'] = DGG.DISABLED
             
             if self.renameButton:
                 self.renameButton['state'] = DGG.DISABLED
 def showLoot(self, plunder = [], gold = 0, collect = 0, card = 0, cloth = 0, color = 0, jewel = None, tattoo = None, weapon = None, bounty = 0):
     for loot in self.loot:
         loot.destroy()
         del loot
     
     self.loot = []
     gender = localAvatar.style.getGender()
     self.show()
     self.setAlphaScale(1.0)
     treasure = []
     for itemId in self.icons.iterkeys():
         count = 0
         for item in plunder:
             if item == itemId:
                 count += 1
                 continue
         
         if count > 0:
             treasure.append([
                 itemId,
                 count])
             continue
     
     plunder = treasure
     if gold:
         plunder.append([
             ItemId.GOLD,
             gold])
         LootPopupPanel.lootSfx.play()
     
     if bounty:
         plunder.append([
             ItemId.BOUNTY,
             bounty])
         LootPopupPanel.lootSfx.play()
     
     if collect:
         plunder.append([
             ItemId.COLLECT,
             collect])
         LootPopupPanel.lootSfx.play()
     
     if card:
         plunder.append([
             ItemId.CARD,
             card])
         LootPopupPanel.lootSfx.play()
     
     if cloth:
         plunder.append([
             ItemId.CLOTHING,
             (cloth, color)])
         LootPopupPanel.lootSfx.play()
     
     if jewel is not None:
         plunder.append([
             ItemId.QUEST_DROP_JEWEL,
             jewel])
         LootPopupPanel.lootSfx.play()
     
     if tattoo is not None:
         plunder.append([
             ItemId.QUEST_DROP_TATTOO,
             tattoo])
         LootPopupPanel.lootSfx.play()
     
     if weapon is not None:
         plunder.append([
             ItemId.QUEST_DROP_WEAPON,
             weapon])
         LootPopupPanel.lootSfx.play()
     
     for item in plunder:
         (itemType, quantity) = item
         if itemType == ItemId.COLLECT:
             itemId = quantity
             howRare = CollectionMap.Collection_Rarity.get(itemId, 0)
             rarityText = PLocalizer.CollectionRarities.get(howRare)
             value = CollectionValues.get(howRare, 0)
             itemName = PLocalizer.Collections[itemId]
             howManyDoIHave = localAvatar.getInventory().getStackQuantity(itemId)
             howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1)
             if howManyDoIHave < howManyINeed:
                 textInfo = PLocalizer.CollectionPopupNewText % (itemName, rarityText, value)
             else:
                 textInfo = PLocalizer.CollectionPopupDuplicateText % (itemName, rarityText, value)
             pic_name = CollectionMap.Assets[itemId]
             lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name)
             iconScale = 0.34999999999999998
         elif itemType == ItemId.CLOTHING:
             (clothingId, colorId) = quantity
             if clothingId in ClothingGlobals.quest_items:
                 textInfo = PLocalizer.getItemName(clothingId)
             else:
                 textInfo = PLocalizer.TailorColorStrings.get(colorId)
                 textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(ItemGlobals.getType(clothingId))
             clothingType = ItemGlobals.getType(clothingId)
             iconScale = 0.13
             if clothingType == 0:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_hat')
             elif clothingType == 1:
                 lootIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
                 iconScale = 0.29999999999999999
             elif clothingType == 2:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_vest')
             elif clothingType == 3:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_coat')
             elif clothingType == 4:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_pants')
             elif clothingType == 5:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_belt')
             elif clothingType == 6:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_sock')
             else:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_booths')
         elif itemType == ItemId.CARD:
             textInfo = PLocalizer.InventoryTypeNames.get(quantity)
             pic_name = ''
             lootIcon = PlayingCardGlobals.getImage('standard', PlayingCardGlobals.getSuit(quantity), PlayingCardGlobals.getRank(quantity))
             iconScale = 0.20000000000000001
         elif itemType == ItemId.GOLD:
             textInfo = PLocalizer.LootGold % str(quantity)
             potionPercent = PotionGlobals.getGoldBoostEffectPercent(localAvatar)
             potionGold = 0
             textInfo = PLocalizer.LootGold % str(quantity)
             if base.cr.newsManager:
                 if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(base.localAvatar.getDoId()) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY):
                     textInfo = PLocalizer.LootGold % str(quantity / 2) + '\n + ' + PLocalizer.LootGoldDouble % str(quantity / 2)
                 
             if potionGold > 0:
                 textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(potionGold)
             
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.BOUNTY:
             textInfo = PLocalizer.LootBounty % str(quantity)
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.CARGO_CRATE:
             if quantity == 1:
                 textInfo = PLocalizer.CargoCrate % quantity
             else:
                 textInfo = PLocalizer.CargoCrateP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_CHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoChest % quantity
             else:
                 textInfo = PLocalizer.CargoChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_SKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoSkChest % quantity
             else:
                 textInfo = PLocalizer.CargoSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSAC:
             if quantity == 1:
                 textInfo = PLocalizer.LootSac % quantity
             else:
                 textInfo = PLocalizer.LootSacP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootChest % quantity
             else:
                 textInfo = PLocalizer.LootChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootSkChest % quantity
             else:
                 textInfo = PLocalizer.LootSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.QUEST_DROP_JEWEL:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.BROW:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_brow')
                 iconScale = (-0.14000000000000001, 0.14000000000000001, 0.14000000000000001)
             elif type == ItemGlobals.EAR:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_ears')
                 iconScale = (-0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.NOSE:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_nose')
                 iconScale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.MOUTH:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_mouth')
                 iconScale = (0.32500000000000001, 0.32500000000000001, 0.32500000000000001)
             elif type == ItemGlobals.LHAND:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_hand')
                 iconScale = (0.125, 0.125, 0.125)
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_TATTOO:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.CHEST:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_chest_male')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.ARM:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_arm')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.FACE:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_face_male')
                 iconScale = 0.10000000000000001
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_WEAPON:
             weaponId = quantity
             iconScale = 0.10000000000000001
             textInfo = None
             lootIcon = None
             iconName = getItemIcons(weaponId)
             if iconName is not None:
                 lootIcon = LootPopupPanel.WeaponIcons.find('**/' + iconName)
                 textInfo = PLocalizer.InventoryTypeNames.get(weaponId)
             
         
         entry = DirectFrame(parent = self, relief = None, geom = lootIcon, geom_scale = iconScale, text = textInfo, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG0, text_pos = (0.070000000000000007, 0.01), text_font = PiratesGlobals.getInterfaceFont())
         entry.setTransparency(1)
         self.loot.append(entry)
     
     self.repackPanels()
Esempio n. 49
0
 def update(self, repId = None, fromUser = 0):
     inv = localAvatar.getInventory()
     if not inv:
         self.notify.warning('SkillPage unable to find inventory')
         return None
     
     if self.tabBar == None:
         return None
     
     if self.demo:
         return None
     
     if fromUser:
         self.lastUserSelectedTab = repId
     
     if repId == None:
         if localAvatar.getGameState() == 'Fishing':
             if self.lastUserSelectedTab:
                 repId = self.lastUserSelectedTab
             else:
                 repId = InventoryType.CannonRep
         elif localAvatar.cannon:
             repId = InventoryType.CannonRep
         elif localAvatar.gameFSM.state == 'ShipPilot':
             repId = InventoryType.SailingRep
         elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
             repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
         elif localAvatar.currentWeaponId and not (localAvatar.isWeaponDrawn) and self.lastUserSelectedTab:
             repId = self.lastUserSelectedTab
         else:
             repId = InventoryType.CannonRep
     
     self.setRep(repId)
     self.tabBar.selectTab(str(repId))
     self.repMeter.setCategory(repId)
     self.repMeter.update(inv.getReputation(repId))
     unSpentId = self.getUnspent()
     amt = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         amt = self.localMods[unSpentId]
     
     self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
     if amt > 0:
         self.unspent['text_fg'] = (0.80000000000000004, 1, 0.80000000000000004, 1)
     else:
         self.unspent['text_fg'] = (1, 1, 1, 1)
     comboSkills = RadialMenu.ComboSkills(repId, 1)
     totalComboSkills = RadialMenu.ComboSkills(repId, 0)
     activeSkills = RadialMenu.ActiveSkills(repId, 1)
     totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
     passiveSkills = RadialMenu.PassiveSkills(repId, 1)
     totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
     self.linkedSkillIds = { }
     linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
     if linkedSkills:
         for skillId in linkedSkills:
             realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
             self.linkedSkillIds[realSkillId] = skillId
         
     
     for excludedSkillId in self.EXCLUDED_SKILLS:
         for skillId in activeSkills:
             if excludedSkillId == skillId:
                 activeSkills.remove(skillId)
                 totalActiveSkills.remove(skillId)
                 continue
         
     
     for spot in self.skillFrames.keys():
         if spot not in totalComboSkills:
             self.skillFrames[spot].hide()
             continue
     
     count = 0
     for skill in totalComboSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in comboSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 1.1100000000000001
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     count = 0
     for skill in totalActiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         (xMod, yMod) = self.ringOffset(count)
         xMod *= 0.90000000000000002
         yMod *= 0.90000000000000002
         if not skill in activeSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = xMod + 0.53000000000000003
         y = yMod + 0.61499999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         ammo = self.getAmmo(skill)
         if ammo != None and showIcon:
             self.skillFrames[skill].showQuantity = True
             self.skillFrames[skill].updateQuantity(ammo)
         
         count += 1
     
     count = 0
     for skill in totalPassiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in passiveSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 0.14999999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     self.dataChanged = False
 def updateText(self):
     tText = PLocalizer.DisplayTitle
     if not Freebooter.getPaidStatus(localAvatar.doId):
         tText = PLocalizer.DisplayTitleFree
     
     self.displayTitleFrame['text'] = tText
    def updateText(self):
        tText = PLocalizer.DisplayTitle
        if not Freebooter.getPaidStatus(localAvatar.doId):
            tText = PLocalizer.DisplayTitleFree

        self.displayTitleFrame['text'] = tText
Esempio n. 52
0
def getAllSkills(repId, skilltrack, wantWeaponSkill = 0):
    inv = base.localAvatar.getInventory()
    if inv == None:
        print 'WARNING - getAllSkills came up with no inventory for ', repId
        return []
    
    minlvl = 2
    choices = []
    if repId == InventoryType.CutlassRep:
        skillId = InventoryType.begin_WeaponSkillCutlass
        while skillId < InventoryType.end_WeaponSkillCutlass:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.MeleeRep:
        skillId = InventoryType.begin_WeaponSkillMelee
        while skillId < InventoryType.end_WeaponSkillMelee:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DaggerRep:
        skillId = InventoryType.begin_WeaponSkillDagger
        while skillId < InventoryType.end_WeaponSkillDagger:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.GrenadeRep:
        skillId = InventoryType.begin_WeaponSkillGrenade
        while skillId < InventoryType.end_WeaponSkillGrenade:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DollRep:
        skillId = InventoryType.begin_WeaponSkillDoll
        while skillId < InventoryType.end_WeaponSkillDoll:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.WandRep:
        skillId = InventoryType.begin_WeaponSkillWand
        while skillId < InventoryType.end_WeaponSkillWand:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.KettleRep:
        skillId = InventoryType.begin_WeaponSkillKettle
        while skillId < InventoryType.end_WeaponSkillKettle:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.PistolRep:
        skillId = InventoryType.begin_WeaponSkillPistol
        while skillId < InventoryType.end_WeaponSkillPistol:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.CannonRep:
        wantWeaponSkill = 0
        skillId = InventoryType.begin_WeaponSkillCannon
        while skillId < InventoryType.end_WeaponSkillCannon:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.SailingRep:
        skillId = InventoryType.begin_SkillSailing
        while skillId < InventoryType.end_SkillSailing:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                shouldBeVisible = inv.getStackQuantity(skillId) >= minlvl
                skill = (skillId, shouldBeVisible, locked)
                choices.append(skill)
            
            skillId += 1
    elif repId == InventoryType.DefenseCannonRep:
        wantWeaponSkill = 0
        for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                skill = (skillId, True, False)
                choices.append(skill)
            
            skillId += 1
        
    elif repId == InventoryType.FishingRep:
        wantWeaponSkill = 0
        skillId = InventoryType.begin_WeaponSkillFishingRod
        skilltrack = 1
        while skillId < InventoryType.end_WeaponSkillFishingRod:
            if WeaponGlobals.getSkillTrack(skillId) == skilltrack:
                locked = False
                if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                    locked = not WeaponGlobals.canFreeUse(skillId)
                
                if inv.getStackQuantity(skillId) >= minlvl:
                    skill = (skillId, True, locked)
                else:
                    skill = (skillId, False, locked)
                choices.append(skill)
            
            skillId += 1
    
    if wantWeaponSkill:
        weaponSkill = getWeaponSkill(repId)
        if weaponSkill:
            choices.append((weaponSkill, True, 0))
        
    
    return choices
 def unlockAmmoFromAI(self, ammoSkillIds):
     for ammoSkillId in ammoSkillIds:
         if Freebooter.getPaidStatus(base.localAvatar.doId) or ammoSkillId <= CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
             self.buttons[ammoSkillId].unlock()
             continue
Esempio n. 54
0
 def unlockAmmoFromAI(self, ammoSkillIds):
     for ammoSkillId in ammoSkillIds:
         if Freebooter.getPaidStatus(base.localAvatar.doId) or ammoSkillId <= CannonDefenseGlobals.FREEBOOTER_LAST_AMMO_AVAILABLE:
             self.buttons[ammoSkillId].unlock()
             continue