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 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 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 not in [ItemId.INTERCEPTOR_L1, ItemId.MERCHANT_L1, ItemId.WARSHIP_L1, ItemId.BRIG_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.05, 0, 0), pos=(0.16, 0, 0.025)) 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.405, 0, -0.015), state=DGG.DISABLED, geom=subCard.find('**/pir_t_gui_gen_key_subscriber'), geom_scale=0.12, geom_pos=(0.06, 0, 0.06)) 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.025)) 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 return
def update(self, value, playFX=False): self.value = value (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(self.category, value) self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level) self.levelLabel["text"] = PLocalizer.Level + " %s" % level if self.category == InventoryType.OverallRep: levelcap = ReputationGlobals.GlobalLevelCap elif self.category in [InventoryType.FishingRep, InventoryType.PotionsRep]: levelcap = ReputationGlobals.MinigameLevelCap else: levelcap = ReputationGlobals.LevelCap if level >= levelcap: self.levelLabel["text_fg"] = PiratesGuiGlobals.TextFG1 self.meter["range"] = self.max self.meter["value"] = self.max self.meter["barColor"] = (180 / 255.0, 190 / 255.0, 140 / 255.0, 1) self.valueLabel.hide() self.showMasterOrnament() if playFX: self.masteredFX() else: self.levelLabel["text_fg"] = PiratesGuiGlobals.TextFG2 self.valueLabel.show() self.valueLabel["text"] = "%s / %s" % (leftoverValue, self.max) self.meter.show() self.meter["range"] = self.max self.meter["value"] = leftoverValue self.meter["barColor"] = (223 / 255.0, 137 / 255.0, 28 / 255.0, 1) self.hideMasterOrnament()
def updateChange(self, value, newValue): self.value = value (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(self.category, value + newValue) self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level) self.levelLabel['text'] = '%s' % level oldValue = leftoverValue - newValue if oldValue < 0: oldValue = 0 if self.category == InventoryType.OverallRep: levelCap = ReputationGlobals.GlobalLevelCap else: levelCap = ReputationGlobals.LevelCap if level == levelCap: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4 self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.valueLabel['text_scale'] = 0.042999999999999997 self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level self.categoryLabel.hide() self.meter.meterFaceHalf1.hide() self.meter.meterFaceHalf2.hide() self.meter.meterFace.setColor(0.10000000000000001, 0.40000000000000002, 0.10000000000000001, 1.0) self.valueLabel.setZ(0.029999999999999999) self.showMasterOrnament() self.masteredFX() else: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.categoryLabel.show() self.valueLabel.hide() self.changeMeter.update(oldValue, leftoverValue, self.max) self.changeMeter.show() self.meter.hide() self.hideMasterOrnament()
def checkLevel(self, repId, minLvl): inv = localAvatar.getInventory() if inv: repAmt = inv.getAccumulator(repId) if minLvl > ReputationGlobals.getLevelFromTotalReputation( repId, repAmt)[0]: self.highlightRed(PLocalizer.LevelRequirement % self.minLvl)
def update(self, value, playFX=False): self.value = value level, leftoverValue = ReputationGlobals.getLevelFromTotalReputation(self.category, value) self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level) self.levelLabel['text'] = PLocalizer.Level + ' %s' % level if self.category == InventoryType.OverallRep: levelcap = ReputationGlobals.GlobalLevelCap else: if self.category in [InventoryType.FishingRep, InventoryType.PotionsRep]: levelcap = ReputationGlobals.MinigameLevelCap else: levelcap = ReputationGlobals.LevelCap if level >= levelcap: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.meter['range'] = self.max self.meter['value'] = self.max self.meter['barColor'] = (180 / 255.0, 190 / 255.0, 140 / 255.0, 1) self.valueLabel.hide() self.showMasterOrnament() if playFX: self.masteredFX() self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG2 self.valueLabel.show() self.valueLabel['text'] = '%s / %s' % (leftoverValue, self.max) self.meter.show() self.meter['range'] = self.max self.meter['value'] = leftoverValue self.meter['barColor'] = (223 / 255.0, 137 / 255.0, 28 / 255.0, 1) self.hideMasterOrnament()
def getItemRequirements(self, itemType, otherAdds=[]): if not itemType: return 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() weaponLevelPass = weaponReq == None or itemLevel >= weaponReq weaponTrainPass = trainingToken == 0 or trainingToken == None or trainingAmt > 0 results['itemLevel'] = (weaponReq, weaponLevelPass and weaponTrainPass) else: results['itemLevel'] = (0, True) return results
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 increaseExp(self, amt, total): self._exp += amt if self._exp > total: return None (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(InventoryType.DefenseCannonRep, self._exp) self.repMeter.update(self._exp) if level > self.lastLevel: base.localAvatar.levelUpMsg(InventoryType.DefenseCannonRep, level, 0) self.lastLevel = level
def __init__(self, quest, rewards): self.width = 1 self.rewards = rewards QuestDetailBase.__init__(self, parent=base.a2dBottomRight, pos=(0.6, 0, 0.52), text_fg=PiratesGuiGlobals.TextFG0) self.initialiseoptions(QuestRewardGUI) self.questComplete = DirectLabel(parent=self, relief=None, text=PLocalizer.QuestCompleted, text_fg=PiratesGuiGlobals.TextFG4, text_font=PiratesGlobals.getPirateOutlineFont(), text_shadow=(0, 0, 0, 1), pos=(-1.32, 0, 0.13), scale=PiratesGuiGlobals.TextScaleTitleMed) gui = loader.loadModel('models/gui/toplevel_gui') gcButton = gui.find('**/treasure_w_coin*') goldCoin = gcButton.copyTo(gcButton) goldCoin.setScale(3) tpMgr.setGraphic('goldCoin', goldCoin) self.popupSfx = loadSfx(SoundGlobals.SFX_GUI_REWARD_POPUP) self.popupSfx.setVolume(0.4) self.reputation = self.rewards.get('reputation', 0) self.totalReputation = 0 self.rewardsContainer = None self.items = self.rewards.get('items', []) if self.items: scale = 0.12 * len(self.items) self.rewardsContainer = InventoryUIRewardsContainer.InventoryUIRewardsContainer(localAvatar.guiMgr.inventoryUIManager, sizeX=scale, sizeZ=scale, countX=len(self.items), countZ=1) self.rewardsContainer.setPos(-0.1, 0, -0.225 - 0.06 * len(self.items)) self.rewardsContainer.reparentTo(self) for itemId in self.items: self.rewardsContainer.addRewardIntoGrid(itemId, self.items.index(itemId), 0) inv = localAvatar.getInventory() if inv: self.totalReputation = localAvatar.getInventory().getReputation(InventoryType.OverallRep) oldLevel, leftoverValue = ReputationGlobals.getLevelFromTotalReputation(InventoryType.OverallRep, self.totalReputation) newLevel, leftoverValue = ReputationGlobals.getLevelFromTotalReputation(InventoryType.OverallRep, self.totalReputation + self.reputation) if oldLevel != newLevel: self.showLevelUp = True else: self.showLevelUp = False self.buildIvals() self.setQuestInfoFromQuest(quest) self.showPanel() return
def updateRep(self, category, value): for i in range(len(self.items)): repId = WeaponGlobals.getRepId(self.items[i][0]) if repId == category: level, leftoverValue = ReputationGlobals.getLevelFromTotalReputation( category, value) max = ReputationGlobals.getReputationNeededToLevel( category, level) if len(self.repMeters) - 1 >= i: self.repMeters[i]['range'] = max self.repMeters[i]['value'] = leftoverValue
def updateRep(self, category, value): for i in range(len(self.items)): repId = WeaponGlobals.getRepId(self.items[i][0]) if repId == category: (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(category, value) max = ReputationGlobals.getReputationNeededToLevel(category, level) if len(self.repMeters) - 1 >= i: self.repMeters[i]['range'] = max self.repMeters[i]['value'] = leftoverValue len(self.repMeters) - 1 >= i
def __init__(self, quest, rewards): self.width = 1 self.rewards = rewards QuestDetailBase.__init__(self, parent = base.a2dBottomRight, pos = (0.59999999999999998, 0, 0.52000000000000002), text_fg = PiratesGuiGlobals.TextFG0) self.initialiseoptions(QuestRewardGUI) self.questComplete = DirectLabel(parent = self, relief = None, text = PLocalizer.QuestCompleted, text_fg = PiratesGuiGlobals.TextFG4, text_font = PiratesGlobals.getPirateOutlineFont(), text_shadow = (0, 0, 0, 1), pos = (-1.3200000000000001, 0, 0.13), scale = PiratesGuiGlobals.TextScaleTitleMed) gui = loader.loadModel('models/gui/toplevel_gui') gcButton = gui.find('**/treasure_w_coin*') goldCoin = gcButton.copyTo(gcButton) goldCoin.setScale(3) tpMgr.setGraphic('goldCoin', goldCoin) self.popupSfx = loadSfx(SoundGlobals.SFX_GUI_REWARD_POPUP) self.popupSfx.setVolume(0.40000000000000002) self.reputation = self.rewards.get('reputation', 0) self.totalReputation = 0 self.rewardsContainer = None self.items = self.rewards.get('items', []) if self.items: scale = 0.12 * len(self.items) self.rewardsContainer = InventoryUIRewardsContainer.InventoryUIRewardsContainer(localAvatar.guiMgr.inventoryUIManager, sizeX = scale, sizeZ = scale, countX = len(self.items), countZ = 1) self.rewardsContainer.setPos(-0.10000000000000001, 0, -0.22500000000000001 - 0.059999999999999998 * len(self.items)) self.rewardsContainer.reparentTo(self) for itemId in self.items: self.rewardsContainer.addRewardIntoGrid(itemId, self.items.index(itemId), 0) inv = localAvatar.getInventory() if inv: self.totalReputation = localAvatar.getInventory().getReputation(InventoryType.OverallRep) (oldLevel, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(InventoryType.OverallRep, self.totalReputation) (newLevel, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(InventoryType.OverallRep, self.totalReputation + self.reputation) if oldLevel != newLevel: self.showLevelUp = True else: self.showLevelUp = False self.buildIvals() self.setQuestInfoFromQuest(quest) self.showPanel()
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 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
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 checkLevel(self, repId, minLvl): inv = localAvatar.getInventory() if inv: repAmt = inv.getAccumulator(repId) if minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]: self.highlightRed(PLocalizer.LevelRequirement % self.minLvl + ' ' + PLocalizer.InventoryItemClassNames.get(EconomyGlobals.getItemType(self.data[0])))
def getPlayerPotionLevel(self): inv = localAvatar.getInventory() repAmt = inv.getAccumulator(InventoryType.PotionsRep) repLvl = ReputationGlobals.getLevelFromTotalReputation(InventoryType.PotionsRep, repAmt) return repLvl[0]
def handleBuyItem(self, data, useCode): itemId = data[0] if not itemId: return None itemType = EconomyGlobals.getItemType(itemId) if itemType <= ItemType.WAND or itemType == ItemType.POTION: data[1] = 1 else: data[1] = EconomyGlobals.getItemQuantity(itemId) inventory = base.localAvatar.getInventory() if not inventory: return None itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getStackQuantity(itemId) currStockLimit = inventory.getStackLimit(itemId) if useCode == PiratesGuiGlobals.InventoryAdd: itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType) trainingReq = EconomyGlobals.getItemTrainingReq(itemId) if trainingReq: amt = inventory.getStackQuantity(trainingReq) if not amt: base.localAvatar.guiMgr.createWarning(PLocalizer.NoTrainingWarning % itemTypeName, PiratesGuiGlobals.TextFG6) return None itemType = EconomyGlobals.getItemType(itemId) if itemType != ItemType.POTION: minLvl = ItemGlobals.getWeaponRequirement(itemId) else: minLvl = 0 repId = WeaponGlobals.getRepId(itemId) repAmt = inventory.getAccumulator(repId) if minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]: base.localAvatar.guiMgr.createWarning(PLocalizer.LevelReqWarning % (minLvl, itemTypeName), PiratesGuiGlobals.TextFG6) return None if itemId in ItemGlobals.getAllWeaponIds(): locatables = [] for dataInfo in self.purchaseInventory.inventory: dataId = dataInfo[0] if dataId in ItemGlobals.getAllWeaponIds(): locatables.append(InvItem([ InventoryType.ItemTypeWeapon, dataId, 0])) continue locatables.append(InvItem([ InventoryType.ItemTypeWeapon, itemId, 0])) locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): base.localAvatar.guiMgr.createWarning(PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6) return None continue elif itemId in ItemGlobals.getAllConsumableIds(): itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getItemQuantity(InventoryType.ItemTypeConsumable, itemId) currStockLimit = inventory.getItemLimit(InventoryType.ItemTypeConsumable, itemId) if currStock + itemQuantity >= currStockLimit: base.localAvatar.guiMgr.createWarning(PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6) return None if currStock == 0: locatables = [] dataIds = { } for dataInfo in self.purchaseInventory.inventory: dataId = dataInfo[0] if dataId in ItemGlobals.getAllConsumableIds(): if dataIds.has_key(dataId): dataIds[dataId] += 1 else: dataIds[dataId] = 1 dataIds.has_key(dataId) if dataIds.has_key(itemId): dataIds[itemId] += 1 else: dataIds[itemId] = 1 for dataId in dataIds: locatables.append(InvItem([ InventoryType.ItemTypeConsumable, dataId, 0, dataIds[dataId]])) locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): base.localAvatar.guiMgr.createWarning(PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6) return None continue else: itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getStackQuantity(itemId) currStockLimit = inventory.getStackLimit(itemId) itemCategory = EconomyGlobals.getItemCategory(itemId) if currStock + itemQuantity >= currStockLimit: base.localAvatar.guiMgr.createWarning(PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6) return None self.purchaseInventory.addPanel(data) self.purchaseInventory.inventory.append(data) elif useCode == PiratesGuiGlobals.InventoryRemove: self.purchaseInventory.removePanel(data) panel = self.storeInventory.getPanel(data) if panel: self.checkPanel(panel, inventory, itemId) self.updateBalance()
def handleBuyItem(self, data, useCode): itemId = data[0] if not itemId: return itemType = EconomyGlobals.getItemType(itemId) if itemType <= ItemType.WAND or itemType == ItemType.POTION: data[1] = 1 else: data[1] = EconomyGlobals.getItemQuantity(itemId) inventory = base.localAvatar.getInventory() if not inventory: return itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getStackQuantity(itemId) currStockLimit = inventory.getStackLimit(itemId) if useCode == PiratesGuiGlobals.InventoryAdd: itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType) trainingReq = EconomyGlobals.getItemTrainingReq(itemId) if trainingReq: amt = inventory.getStackQuantity(trainingReq) if not amt: base.localAvatar.guiMgr.createWarning( PLocalizer.NoTrainingWarning % itemTypeName, PiratesGuiGlobals.TextFG6) return itemType = EconomyGlobals.getItemType(itemId) if itemType != ItemType.POTION: minLvl = ItemGlobals.getWeaponRequirement(itemId) else: minLvl = 0 repId = WeaponGlobals.getRepId(itemId) repAmt = inventory.getAccumulator(repId) if minLvl > ReputationGlobals.getLevelFromTotalReputation( repId, repAmt)[0]: base.localAvatar.guiMgr.createWarning( PLocalizer.LevelReqWarning % (minLvl, itemTypeName), PiratesGuiGlobals.TextFG6) return if itemId in ItemGlobals.getAllWeaponIds(): locatables = [] for dataInfo in self.purchaseInventory.inventory: dataId = dataInfo[0] if dataId in ItemGlobals.getAllWeaponIds(): locatables.append( InvItem([InventoryType.ItemTypeWeapon, dataId, 0])) locatables.append( InvItem([InventoryType.ItemTypeWeapon, itemId, 0])) locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): base.localAvatar.guiMgr.createWarning( PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6) return else: if itemId in ItemGlobals.getAllConsumableIds(): itemQuantity = self.purchaseInventory.getItemQuantity( itemId) currStock = inventory.getItemQuantity( InventoryType.ItemTypeConsumable, itemId) currStockLimit = inventory.getItemLimit( InventoryType.ItemTypeConsumable, itemId) if currStock + itemQuantity >= currStockLimit: base.localAvatar.guiMgr.createWarning( PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6) return if currStock == 0: locatables = [] dataIds = {} for dataInfo in self.purchaseInventory.inventory: dataId = dataInfo[0] if dataId in ItemGlobals.getAllConsumableIds(): if dataIds.has_key(dataId): dataIds[dataId] += 1 else: dataIds[dataId] = 1 if dataIds.has_key(itemId): dataIds[itemId] += 1 else: dataIds[itemId] = 1 for dataId in dataIds: locatables.append( InvItem([ InventoryType.ItemTypeConsumable, dataId, 0, dataIds[dataId] ])) locationIds = inventory.canAddLocatables(locatables) for locationId in locationIds: if locationId in (Locations.INVALID_LOCATION, Locations.NON_LOCATION): base.localAvatar.guiMgr.createWarning( PLocalizer.InventoryFullWarning, PiratesGuiGlobals.TextFG6) return itemQuantity = self.purchaseInventory.getItemQuantity(itemId) currStock = inventory.getStackQuantity(itemId) currStockLimit = inventory.getStackLimit(itemId) itemCategory = EconomyGlobals.getItemCategory(itemId) if currStock + itemQuantity >= currStockLimit: base.localAvatar.guiMgr.createWarning( PLocalizer.TradeItemFullWarning, PiratesGuiGlobals.TextFG6) return self.purchaseInventory.addPanel(data) self.purchaseInventory.inventory.append(data) elif useCode == PiratesGuiGlobals.InventoryRemove: self.purchaseInventory.removePanel(data) panel = self.storeInventory.getPanel(data) if panel: self.checkPanel(panel, inventory, itemId) self.updateBalance()
def update(self, value, updateLocal=0): if self.mastered: return None self.value = value (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation( self.category, value) self.max = ReputationGlobals.getReputationNeededToLevel( self.category, level) self.levelLabel['text'] = '%s' % level if self.category == InventoryType.OverallRep: levelCap = ReputationGlobals.GlobalLevelCap if updateLocal and level != self.level: localAvatar.setLevel(level) else: levelCap = ReputationGlobals.LevelCap self.level = level if level == levelCap: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4 self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.valueLabel['text_scale'] = 0.042999999999999997 self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level self.categoryLabel.hide() self.meter.meterFaceHalf1.hide() self.meter.meterFaceHalf2.hide() self.meter.meterFace.setColor(0.10000000000000001, 0.40000000000000002, 0.10000000000000001, 1.0) self.valueLabel.setZ(0.029999999999999999) self.showMasterOrnament() self.masteredFX() else: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.meter.show() self.categoryLabel.show() self.valueLabel['text'] = '%s / %s' % (leftoverValue, self.max) self.valueLabel['text_scale'] = PiratesGuiGlobals.TextScaleLarge self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG2 self.valueLabel.setZ(0.0) self.meter.update(leftoverValue, self.max) self.hideMasterOrnament() if self.lastLevel == None: self.lastLevel = level if self.lastExp == None: if hasattr(base, 'localAvatar'): self.lastExp = localAvatar.getInventory().getReputation( self.category) if self.lastExp: expChange = value - self.lastExp if expChange and localAvatar.getGameState() != 'Fishing': localAvatar.guiMgr.gameGui.createExpAlert( expChange, 4.0, Vec3(-0.93000000000000005, 0.0, 0.75), Vec3(0.0, 0.0, 0.25)) if self.lastLevel != level: self.lastLevel = level glowFrameColor = Vec4(0.69999999999999996, 0.0, 0.0, 1.0) glowLevelColor = Vec4(0.80000000000000004, 0.0, 0.0, 1.0) startFrameColor = self.meter.meterFace.getColor() startLevelColor = Vec4(0.90000000000000002, 0.80000000000000004, 0.63, 1.0) startFrameScale = self.meter.meterFace.getScale() startLevelScale = self.levelLabel.getScale() scale = Vec3(1.2, 1.2, 1.2) objFrame = self.meter.meterFace objLevel = self.levelLabel levelUpIval = Sequence( Func(self.meter.meterFaceHalf1.hide), Func(self.meter.meterFaceHalf2.hide), Parallel( LerpColorInterval(objFrame, 3.0, startFrameColor, glowFrameColor, blendType='easeInOut'), LerpColorInterval(objLevel, 3.0, startLevelColor, glowLevelColor, blendType='easeInOut'), Sequence( LerpScaleInterval(objLevel, 0.25, scale, startFrameScale, blendType='easeInOut'), LerpScaleInterval(objLevel, 2.0, startFrameScale, blendType='easeInOut'))), Func(self.meter.meterFaceHalf1.show), Func(self.meter.meterFaceHalf2.show), Func(objLevel.clearColor)) levelUpIval.start() elif self.lastExp is not None: if self.lastExp == value: return None self.lastExp = value glowFrameColor = Vec4(1.0, 0, 0, 1.0) startFrameColorA = self.meter.meterFaceHalf1.getColor() startFrameColorB = self.meter.meterFaceHalf2.getColor() objFrameA = self.meter.meterFaceHalf1 objFrameB = self.meter.meterFaceHalf2 objFrameC = self.meter.meterFace if leftoverValue and float(self.max) / float(leftoverValue) > 2.0: expUpIval = Sequence( LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType='easeInOut'), Wait(0.20000000000000001), LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType='easeInOut'), LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType='easeInOut'), Wait(0.10000000000000001), LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType='easeInOut')) else: expUpIval = Sequence( Parallel( LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType='easeInOut'), LerpColorScaleInterval(objFrameB, 0.20000000000000001, glowFrameColor, blendType='easeInOut')), Wait(0.20000000000000001), Parallel( LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType='easeInOut'), LerpColorScaleInterval(objFrameB, 0.5, startFrameColorA, blendType='easeInOut')), Parallel( LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType='easeInOut'), LerpColorScaleInterval(objFrameB, 0.10000000000000001, glowFrameColor, blendType='easeInOut')), Wait(0.10000000000000001), Parallel( LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType='easeInOut'), LerpColorScaleInterval(objFrameB, 0.29999999999999999, startFrameColorA, blendType='easeInOut'))) expUpIval.start()
def update(self, value, updateLocal = 0): if self.mastered: return None self.value = value (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(self.category, value) self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level) self.levelLabel['text'] = '%s' % level if self.category == InventoryType.OverallRep: levelCap = ReputationGlobals.GlobalLevelCap if updateLocal and level != self.level: localAvatar.setLevel(level) else: levelCap = ReputationGlobals.LevelCap self.level = level if level == levelCap: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4 self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.valueLabel['text_scale'] = 0.042999999999999997 self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level self.categoryLabel.hide() self.meter.meterFaceHalf1.hide() self.meter.meterFaceHalf2.hide() self.meter.meterFace.setColor(0.10000000000000001, 0.40000000000000002, 0.10000000000000001, 1.0) self.valueLabel.setZ(0.029999999999999999) self.showMasterOrnament() self.masteredFX() else: self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1 self.meter.show() self.categoryLabel.show() self.valueLabel['text'] = '%s / %s' % (leftoverValue, self.max) self.valueLabel['text_scale'] = PiratesGuiGlobals.TextScaleLarge self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG2 self.valueLabel.setZ(0.0) self.meter.update(leftoverValue, self.max) self.hideMasterOrnament() if self.lastLevel == None: self.lastLevel = level if self.lastExp == None: if hasattr(base, 'localAvatar'): self.lastExp = localAvatar.getInventory().getReputation(self.category) if self.lastExp: expChange = value - self.lastExp if expChange and localAvatar.getGameState() != 'Fishing': localAvatar.guiMgr.gameGui.createExpAlert(expChange, 4.0, Vec3(-0.93000000000000005, 0.0, 0.75), Vec3(0.0, 0.0, 0.25)) if self.lastLevel != level: self.lastLevel = level glowFrameColor = Vec4(0.69999999999999996, 0.0, 0.0, 1.0) glowLevelColor = Vec4(0.80000000000000004, 0.0, 0.0, 1.0) startFrameColor = self.meter.meterFace.getColor() startLevelColor = Vec4(0.90000000000000002, 0.80000000000000004, 0.63, 1.0) startFrameScale = self.meter.meterFace.getScale() startLevelScale = self.levelLabel.getScale() scale = Vec3(1.2, 1.2, 1.2) objFrame = self.meter.meterFace objLevel = self.levelLabel levelUpIval = Sequence(Func(self.meter.meterFaceHalf1.hide), Func(self.meter.meterFaceHalf2.hide), Parallel(LerpColorInterval(objFrame, 3.0, startFrameColor, glowFrameColor, blendType = 'easeInOut'), LerpColorInterval(objLevel, 3.0, startLevelColor, glowLevelColor, blendType = 'easeInOut'), Sequence(LerpScaleInterval(objLevel, 0.25, scale, startFrameScale, blendType = 'easeInOut'), LerpScaleInterval(objLevel, 2.0, startFrameScale, blendType = 'easeInOut'))), Func(self.meter.meterFaceHalf1.show), Func(self.meter.meterFaceHalf2.show), Func(objLevel.clearColor)) levelUpIval.start() elif self.lastExp is not None: if self.lastExp == value: return None self.lastExp = value glowFrameColor = Vec4(1.0, 0, 0, 1.0) startFrameColorA = self.meter.meterFaceHalf1.getColor() startFrameColorB = self.meter.meterFaceHalf2.getColor() objFrameA = self.meter.meterFaceHalf1 objFrameB = self.meter.meterFaceHalf2 objFrameC = self.meter.meterFace if leftoverValue and float(self.max) / float(leftoverValue) > 2.0: expUpIval = Sequence(LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut'), Wait(0.20000000000000001), LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut'), Wait(0.10000000000000001), LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut')) else: expUpIval = Sequence(Parallel(LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut')), Wait(0.20000000000000001), Parallel(LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.5, startFrameColorA, blendType = 'easeInOut')), Parallel(LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut')), Wait(0.10000000000000001), Parallel(LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut'))) expUpIval.start()
def checkLevel(self, repId, minLvl): inv = localAvatar.getInventory() if inv: repAmt = inv.getAccumulator(repId) if minLvl > ReputationGlobals.getLevelFromTotalReputation(repId, repAmt)[0]: self.highlightRed(PLocalizer.LevelRequirement % self.minLvl)
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 caughtFish(self, fishId, weight): avatar = self.air.doId2do.get(self.air.getAvatarIdFromSender()) if not avatar: return fishData = FishingGlobals.getFishData(fishId) if not fishData: self.air.logPotentialHacker( message='Received caughtFish update for an invalid fish!', accountId=self.air.getAccountIdFromSender(), fishId=fishId, weight=weight) return minWeight, maxWeight = fishData['weightRange'] if weight < minWeight or weight > maxWeight: self.air.logPotentialHacker( message='Received caughtFish update for invalid weight.', accountId=self.air.getAccountIdFromSender(), fishId=fishId, weight=weight) return reward = fishData['gold'] * weight bonusReward = 0 if self.air.holidayMgr.isHolidayActive( HolidayGlobals.DOUBLEGOLDHOLIDAY ) or self.air.holidayMgr.isHolidayActive( HolidayGlobals.DOUBLEGOLDHOLIDAYPAID): bonusReward = reward * 2 if bonusReward: reward += bonusReward self.sendUpdateToAvatarId(avatar.doId, 'setGoldBonus', [bonusReward]) experience = fishData['experience'] bonusExperience = 0 if self.air.holidayMgr.isHolidayActive(HolidayGlobals.DOUBLEXPHOLIDAY): bonusExperience = experience * 2 if bonusExperience: experience += bonusExperience self.sendUpdateToAvatarId(avatar.doId, 'setXpBonus', [bonusExperience]) inventory = self.air.inventoryManager.getInventory(avatar.doId) if not inventory: self.notify.warning('Failed to get inventory for avatar %d!' % avatar.doId) return currentLevel = ReputationGlobals.getLevelFromTotalReputation( InventoryType.FishingRep, inventory.getFishingRep())[0] expectedLevel = ReputationGlobals.getLevelFromTotalReputation( InventoryType.FishingRep, inventory.getFishingRep() + experience)[0] if expectedLevel > currentLevel: if expectedLevel in FishingGlobals.unlockLevelToSkillId: unlockedSkill = FishingGlobals.unlockLevelToSkillId[ expectedLevel] inventory.b_setStack(unlockedSkill, 1) inventory.setGoldInPocket(inventory.getGoldInPocket() + reward) inventory.setFishingRep(inventory.getFishingRep() + experience) # Clear Tutorial flags if not inventory.getStack(InventoryType.FishingTutorial): inventory.b_setStack(InventoryType.FishingTutorial, 1)
def getPlayerPotionLevel(self): inv = localAvatar.getInventory() repAmt = inv.getAccumulator(InventoryType.PotionsRep) repLvl = ReputationGlobals.getLevelFromTotalReputation( InventoryType.PotionsRep, repAmt) return repLvl[0]
def showWeaponNotoriety(self): totalReputation = 0 inv = localAvatar.getInventory() level = localAvatar.getLevel() maxLevel = ReputationGlobals.GlobalLevelCap if level < maxLevel: textStr = PLocalizer.RewardNotorietyLessThanMax % (level, maxLevel) textScale = 0.050000000000000003 labelY = 0.37 buttonY = 0.10000000000000001 else: textStr = PLocalizer.RewardNotorietyAtMax % maxLevel textScale = 0.040000000000000001 self.congratsText.show() labelY = 0.25 buttonY = 0.13 self.notorietyText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = textStr, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = textScale, text_fg = PiratesGuiGlobals.TextFG1, pos = (0, 0, labelY)) self.notorietyText.hide() if level < maxLevel: self.todoText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = PLocalizer.RewardTodo, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.035000000000000003, text_fg = PiratesGuiGlobals.TextFG1, pos = (0, 0, 0.19)) self.todoText.hide() else: self.stayTunedText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, textMayChange = 1, text = PLocalizer.RewardStayTuned, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_align = TextNode.ACenter, text_scale = 0.035000000000000003, text_fg = PiratesGuiGlobals.TextFG1, pos = (0, 0, -0.40999999999999998)) self.stayTunedText.hide() weapons = [ [ InventoryType.CutlassToken, InventoryType.CutlassRep], [ InventoryType.PistolToken, InventoryType.PistolRep], [ InventoryType.DaggerToken, InventoryType.DaggerRep], [ InventoryType.GrenadeToken, InventoryType.GrenadeRep], [ InventoryType.WandToken, InventoryType.WandRep], [ InventoryType.DollToken, InventoryType.DollRep], [ InventoryType.NewPlayerToken, InventoryType.CannonRep], [ InventoryType.NewPlayerToken, InventoryType.SailingRep]] maxRep = ReputationGlobals.getTotalReputation(InventoryType.GeneralRep, ReputationGlobals.LevelCap) self.guiElements = [] i = 0 for (weaponToken, weaponId) in weapons: weaponUnlocked = False levelText = PLocalizer.RewardLevelLocked state = 0 if inv.getStackQuantity(weaponToken): weaponUnlocked = True if weaponUnlocked: rep = inv.getReputation(weaponId) (wlevel, value) = ReputationGlobals.getLevelFromTotalReputation(weaponId, rep) levelText = PLocalizer.RewardLevelOfMax % (wlevel, ReputationGlobals.LevelCap) if rep >= maxRep: levelText = PLocalizer.RepCapText_Skill state = 1 cb = self.makeCheckbox((0, 0, buttonY - 0.065000000000000002 * i), PLocalizer.InventoryTypeNames[weaponId], None, state, [ 3], levelText) cb['indicatorValue'] = state cb.hide() self.guiElements.append(cb) i += 1 self.showWeaponsTrack = Sequence() self.showWeaponsTrack.append(Sequence(Func(self.notorietyText.show), Wait(1))) if level < maxLevel: self.showWeaponsTrack.append(Sequence(Func(self.todoText.show), Wait(1))) for b in self.guiElements: self.showWeaponsTrack.append(Sequence(Func(b.show), Wait(0.5))) if level >= maxLevel: self.showWeaponsTrack.append(Sequence(Func(self.stayTunedText.show), Wait(1))) self.showWeaponsTrack.append(Func(self.nextButton.show)) self.showWeaponsTrack.start()
def showWeaponNotoriety(self): totalReputation = 0 inv = localAvatar.getInventory() level = localAvatar.getLevel() maxLevel = ReputationGlobals.GlobalLevelCap if level < maxLevel: textStr = PLocalizer.RewardNotorietyLessThanMax % (level, maxLevel) textScale = 0.05 labelY = 0.37 buttonY = 0.1 else: textStr = PLocalizer.RewardNotorietyAtMax % maxLevel textScale = 0.04 self.congratsText.show() labelY = 0.25 buttonY = 0.13 self.notorietyText = DirectLabel( parent=self, relief=None, state=DGG.DISABLED, textMayChange=1, text=textStr, text_font=PiratesGlobals.getInterfaceOutlineFont(), text_align=TextNode.ACenter, text_scale=textScale, text_fg=PiratesGuiGlobals.TextFG1, pos=(0, 0, labelY)) self.notorietyText.hide() if level < maxLevel: self.todoText = DirectLabel( parent=self, relief=None, state=DGG.DISABLED, textMayChange=1, text=PLocalizer.RewardTodo, text_font=PiratesGlobals.getInterfaceOutlineFont(), text_align=TextNode.ACenter, text_scale=0.035, text_fg=PiratesGuiGlobals.TextFG1, pos=(0, 0, 0.19)) self.todoText.hide() else: self.stayTunedText = DirectLabel( parent=self, relief=None, state=DGG.DISABLED, textMayChange=1, text=PLocalizer.RewardStayTuned, text_font=PiratesGlobals.getInterfaceOutlineFont(), text_align=TextNode.ACenter, text_scale=0.035, text_fg=PiratesGuiGlobals.TextFG1, pos=(0, 0, -0.41)) self.stayTunedText.hide() weapons = [[InventoryType.CutlassToken, InventoryType.CutlassRep], [InventoryType.PistolToken, InventoryType.PistolRep], [InventoryType.DaggerToken, InventoryType.DaggerRep], [InventoryType.GrenadeToken, InventoryType.GrenadeRep], [InventoryType.WandToken, InventoryType.WandRep], [InventoryType.DollToken, InventoryType.DollRep], [InventoryType.NewPlayerToken, InventoryType.CannonRep], [InventoryType.NewPlayerToken, InventoryType.SailingRep]] maxRep = ReputationGlobals.getTotalReputation( InventoryType.GeneralRep, ReputationGlobals.LevelCap) self.guiElements = [] i = 0 for weaponToken, weaponId in weapons: weaponUnlocked = False levelText = PLocalizer.RewardLevelLocked state = 0 if inv.getStackQuantity(weaponToken): weaponUnlocked = True if weaponUnlocked: rep = inv.getReputation(weaponId) wlevel, value = ReputationGlobals.getLevelFromTotalReputation( weaponId, rep) levelText = PLocalizer.RewardLevelOfMax % ( wlevel, ReputationGlobals.LevelCap) if rep >= maxRep: levelText = PLocalizer.RepCapText_Skill state = 1 cb = self.makeCheckbox((0, 0, buttonY - 0.065 * i), PLocalizer.InventoryTypeNames[weaponId], None, state, [3], levelText) cb['indicatorValue'] = state cb.hide() self.guiElements.append(cb) i += 1 self.showWeaponsTrack = Sequence() self.showWeaponsTrack.append( Sequence(Func(self.notorietyText.show), Wait(1))) if level < maxLevel: self.showWeaponsTrack.append( Sequence(Func(self.todoText.show), Wait(1))) for b in self.guiElements: self.showWeaponsTrack.append(Sequence(Func(b.show), Wait(0.5))) if level >= maxLevel: self.showWeaponsTrack.append( Sequence(Func(self.stayTunedText.show), Wait(1))) self.showWeaponsTrack.append(Func(self.nextButton.show)) self.showWeaponsTrack.start() return
def createHelpbox(self, args = None): if self.helpFrame: return None itemType = EconomyGlobals.getItemType(self.data[0]) if itemType <= ItemType.WAND or itemType == ItemType.POTION: itemId = self.data[0] self.helpFrame = DirectFrame(parent = aspect2d, relief = None, state = DGG.DISABLED, sortOrder = 1) 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 textScale = PiratesGuiGlobals.TextScaleMed titleScale = PiratesGuiGlobals.TextScaleTitleSmall 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 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' elif rarity == ItemGlobals.COMMON: titleColor = PiratesGuiGlobals.TextFG13 itemColor = 'itemYellow' elif rarity == ItemGlobals.RARE: titleColor = PiratesGuiGlobals.TextFG4 itemColor = 'itemGreen' elif rarity == ItemGlobals.FAMED: titleColor = PiratesGuiGlobals.TextFG5 itemColor = 'itemBlue' titleLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemName(itemId), 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: if itemType == ItemGlobals.GRENADE: self.realItem = loader.loadModel('models/ammunition/' + model) elif itemType == ItemGlobals.POTION: self.realItem = loader.loadModel('models/inventory/' + 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]) elif itemType == ItemGlobals.SWORD: self.realItem.setPos(-1.5, 3.0, -0.29999999999999999) self.realItem.setHpr(90, 170, -90) elif itemSubtype in (ItemGlobals.MUSKET, ItemGlobals.BAYONET): self.realItem.setPos(-1.2, 3.0, -0.10000000000000001) self.realItem.setHpr(0, 135, 10) elif itemSubtype == ItemGlobals.BLUNDERBUSS: self.realItem.setPos(-0.29999999999999999, 2.0, 0.0) self.realItem.setHpr(0, 90, 0) elif itemType == ItemGlobals.GUN: self.realItem.setPos(-0.5, 2.0, -0.20000000000000001) self.realItem.setHpr(0, 90, 0) elif itemType == ItemGlobals.DOLL: self.realItem.setPos(0.0, 1.8999999999999999, -0.10000000000000001) self.realItem.setHpr(0, 90, 180) elif itemType == ItemGlobals.DAGGER: self.realItem.setPos(-1.0, 2.0, -0.29999999999999999) self.realItem.setHpr(90, 170, -90) elif itemType == ItemGlobals.GRENADE: self.realItem.setPos(0.0, 3.5, -0.20000000000000001) self.realItem.setHpr(0, 0, 0) elif itemType == ItemGlobals.STAFF: self.realItem.setPos(-0.40000000000000002, 3.0, -0.29999999999999999) self.realItem.setHpr(-90, 15, -90) elif itemSubtype == ItemGlobals.RAM: self.realItem.setPos(-1.5, 1.5, -0.59999999999999998) self.realItem.setHpr(70, 160, -90) elif itemType == ItemGlobals.POTION: self.realItem.setPos(0.0, 2.5, -0.40000000000000002) self.realItem.setHpr(45, 0, 0) else: self.realItem.setPos(0.0, 1.5, -0.059999999999999998) self.realItem.setHpr(0, 90, 0) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17499999999999999 self.createBuffer() self.itemCard.setZ(runningVertPosition - 0.059999999999999998) runningVertPosition -= iHeight runningSize += iHeight labels.append(self.itemCard) goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(int(ItemGlobals.getGoldCost(itemId) * ItemGlobals.GOLD_SALE_MULTIPLIER)), 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) 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))) if itemType != ItemGlobals.POTION: 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.080000000000000002 runningVertPosition -= iHeight runningSize += iHeight labels.append(infoLabel) specialAttack = None if itemType != ItemGlobals.POTION: 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(), 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.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 = 0.033500000000000002, 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 = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / 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.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) inv = localAvatar.getInventory() 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.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) weaponText = PLocalizer.ItemLevelRequirement % (weaponReq, PLocalizer.getItemTypeName(itemType)) elif 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.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) if itemType != ItemGlobals.POTION: lineBreakBottomPanel = panels.attachNewNode('lineBreakBottomPanel') detailGui.find('**/line_break_bottom').copyTo(lineBreakBottomPanel) lineBreakBottomPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007) lineBreakBottomPanel.setZ(-0.014999999999999999) lineBreakBottomPanel.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) self.helpFrame.setBin('gui-popup', 0) self.helpFrame.setPos(self, 0.55000000000000004, 0, -0.29999999999999999) zOffset = -0.5 - self.helpFrame.getPos(aspect2d)[2] if zOffset >= 0.0: self.helpFrame.setPos(self, 0.55000000000000004, 0, zOffset - 0.29999999999999999) else: weaponInfo = PLocalizer.WeaponDescriptions.get(self.data[0]) weaponDesc = weaponInfo self.helpText = DirectFrame(parent = self, relief = None, text = weaponDesc, state = DGG.DISABLED, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 13, textMayChange = 0, sortOrder = 91) height = -self.helpText.getHeight() self.helpFrame = BorderFrame(parent = aspect2d, state = DGG.DISABLED, frameSize = (-0.029999999999999999, 0.42999999999999999, height, 0.050000000000000003), sortOrder = 90, borderScale = 0.20000000000000001) self.helpText.reparentTo(self.helpFrame) self.helpFrame.setBin('gui-popup', 0) self.helpFrame.setPos(self, 0.25, 0, -0.035000000000000003)
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 = '\x001slant\x001%s %s\x002' % (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)
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 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
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 = 'slant%s %s' % (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) goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(int(ItemGlobals.getGoldCost(itemId) * ItemGlobals.GOLD_SALE_MULTIPLIER)), 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)