def makeBoostDisplay(self, skillId, points): if skillId == InventoryType.SailPowerRecharge: return None if skillId not in self.skillFrames: return None if skillId not in self.boostDisplays: self.backFrames[skillId] = DirectLabel( parent=self.skillFrames[skillId], pos=(0.040000000000000001, 0, -0.040000000000000001), frameColor=(0.20999999999999999, 0.125, 0.035000000000000003, 1), frameSize=(-0.023, 0.023, -0.023, 0.023)) self.boostDisplays[skillId] = DirectLabel( parent=self.skillFrames[skillId], text='', text_scale=PiratesGuiGlobals.TextScaleMed, text_pos=(0.0, -0.01), text_shadow=PiratesGuiGlobals.TextShadow, pos=(0.040000000000000001, 0, -0.040000000000000001), frameColor=(0, 0, 0, 1), frameSize=(-0.02, 0.02, -0.02, 0.02)) self.backFrames[skillId].setBin('gui-fixed', 1) self.boostDisplays[skillId].setBin('gui-fixed', 1) itemBoost = 0 if localAvatar.currentWeaponId: if skillId in ItemGlobals.getLinkedSkills( localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(skillId) itemBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, linkedSkillId) itemBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), linkedSkillId) else: itemBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, skillId) itemBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), skillId) elif localAvatar.getCurrentCharm(): itemBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), skillId) shipBoost = 0 if localAvatar.ship: shipBoost = localAvatar.ship.getSkillBoost(skillId) if itemBoost or shipBoost: self.boostDisplays[skillId]['text'] = str(points + itemBoost + shipBoost) self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG11 return None self.boostDisplays[skillId]['text'] = str(points) if points == 5: self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG18 else: self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG2
def makeBoostDisplay(self, skillId, points): if skillId == InventoryType.SailPowerRecharge: return None if skillId not in self.skillFrames: return None if skillId not in self.boostDisplays: self.backFrames[skillId] = DirectLabel(parent = self.skillFrames[skillId], pos = (0.040000000000000001, 0, -0.040000000000000001), frameColor = (0.20999999999999999, 0.125, 0.035000000000000003, 1), frameSize = (-0.023, 0.023, -0.023, 0.023)) self.boostDisplays[skillId] = DirectLabel(parent = self.skillFrames[skillId], text = '', text_scale = PiratesGuiGlobals.TextScaleMed, text_pos = (0.0, -0.01), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.040000000000000001, 0, -0.040000000000000001), frameColor = (0, 0, 0, 1), frameSize = (-0.02, 0.02, -0.02, 0.02)) self.backFrames[skillId].setBin('gui-fixed', 1) self.boostDisplays[skillId].setBin('gui-fixed', 1) itemBoost = 0 if localAvatar.currentWeaponId: if skillId in ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(skillId) itemBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, linkedSkillId) itemBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), linkedSkillId) else: itemBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, skillId) itemBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), skillId) elif localAvatar.getCurrentCharm(): itemBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), skillId) shipBoost = 0 if localAvatar.ship: shipBoost = localAvatar.ship.getSkillBoost(skillId) if itemBoost or shipBoost: self.boostDisplays[skillId]['text'] = str(points + itemBoost + shipBoost) self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG11 return None self.boostDisplays[skillId]['text'] = str(points) if points == 5: self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG18 else: self.boostDisplays[skillId]['text_fg'] = PiratesGuiGlobals.TextFG2
def update(self, repId = None, fromUser = 0): inv = localAvatar.getInventory() if not inv: self.notify.warning('SkillPage unable to find inventory') return None if self.tabBar == None: return None if self.demo: return None if fromUser: self.lastUserSelectedTab = repId if repId == None: if localAvatar.getGameState() == 'Fishing': if self.lastUserSelectedTab: repId = self.lastUserSelectedTab else: repId = InventoryType.CannonRep elif localAvatar.cannon: repId = InventoryType.CannonRep elif localAvatar.gameFSM.state == 'ShipPilot': repId = InventoryType.SailingRep elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn: repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId) elif localAvatar.currentWeaponId and not (localAvatar.isWeaponDrawn) and self.lastUserSelectedTab: repId = self.lastUserSelectedTab else: repId = InventoryType.CannonRep self.setRep(repId) self.tabBar.selectTab(str(repId)) self.repMeter.setCategory(repId) self.repMeter.update(inv.getReputation(repId)) unSpentId = self.getUnspent() amt = inv.getStackQuantity(unSpentId) if unSpentId in self.localMods: amt = self.localMods[unSpentId] self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt if amt > 0: self.unspent['text_fg'] = (0.80000000000000004, 1, 0.80000000000000004, 1) else: self.unspent['text_fg'] = (1, 1, 1, 1) comboSkills = RadialMenu.ComboSkills(repId, 1) totalComboSkills = RadialMenu.ComboSkills(repId, 0) activeSkills = RadialMenu.ActiveSkills(repId, 1) totalActiveSkills = RadialMenu.ActiveSkills(repId, 0) passiveSkills = RadialMenu.PassiveSkills(repId, 1) totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0) self.linkedSkillIds = { } linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId) if linkedSkills: for skillId in linkedSkills: realSkillId = WeaponGlobals.getLinkedSkillId(skillId) self.linkedSkillIds[realSkillId] = skillId for excludedSkillId in self.EXCLUDED_SKILLS: for skillId in activeSkills: if excludedSkillId == skillId: activeSkills.remove(skillId) totalActiveSkills.remove(skillId) continue for spot in self.skillFrames.keys(): if spot not in totalComboSkills: self.skillFrames[spot].hide() continue count = 0 for skill in totalComboSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] if not skill in comboSkills: pass showIcon = skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = 0.20000000000000001 + 0.17499999999999999 * count y = 1.1100000000000001 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5] count += 1 count = 0 for skill in totalActiveSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] (xMod, yMod) = self.ringOffset(count) xMod *= 0.90000000000000002 yMod *= 0.90000000000000002 if not skill in activeSkills: pass showIcon = skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = xMod + 0.53000000000000003 y = yMod + 0.61499999999999999 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5] ammo = self.getAmmo(skill) if ammo != None and showIcon: self.skillFrames[skill].showQuantity = True self.skillFrames[skill].updateQuantity(ammo) count += 1 count = 0 for skill in totalPassiveSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] if not skill in passiveSkills: pass showIcon = skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = 0.20000000000000001 + 0.17499999999999999 * count y = 0.14999999999999999 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5] count += 1 self.dataChanged = False
def update(self, repId=None, fromUser=0): inv = localAvatar.getInventory() if not inv: self.notify.warning('SkillPage unable to find inventory') return if self.tabBar == None: return if self.demo: return if fromUser: self.lastUserSelectedTab = repId if repId == None: if localAvatar.getGameState() == 'Fishing': if self.lastUserSelectedTab: repId = self.lastUserSelectedTab else: repId = InventoryType.CannonRep elif localAvatar.cannon: repId = InventoryType.CannonRep elif localAvatar.gameFSM.state == 'ShipPilot': repId = InventoryType.SailingRep elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn: repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId) elif localAvatar.currentWeaponId and not localAvatar.isWeaponDrawn and self.lastUserSelectedTab: repId = self.lastUserSelectedTab else: repId = InventoryType.CannonRep self.setRep(repId) self.tabBar.selectTab(str(repId)) self.repMeter.setCategory(repId) self.repMeter.update(inv.getReputation(repId)) unSpentId = self.getUnspent() amt = inv.getStackQuantity(unSpentId) if unSpentId in self.localMods: amt = self.localMods[unSpentId] self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt if amt > 0: self.unspent['text_fg'] = (0.8, 1, 0.8, 1) else: self.unspent['text_fg'] = (1, 1, 1, 1) comboSkills = RadialMenu.ComboSkills(repId, 1) totalComboSkills = RadialMenu.ComboSkills(repId, 0) activeSkills = RadialMenu.ActiveSkills(repId, 1) totalActiveSkills = RadialMenu.ActiveSkills(repId, 0) passiveSkills = RadialMenu.PassiveSkills(repId, 1) totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0) self.linkedSkillIds = {} linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId) if linkedSkills: for skillId in linkedSkills: realSkillId = WeaponGlobals.getLinkedSkillId(skillId) self.linkedSkillIds[realSkillId] = skillId for excludedSkillId in self.EXCLUDED_SKILLS: for skillId in activeSkills: if excludedSkillId == skillId: activeSkills.remove(skillId) totalActiveSkills.remove(skillId) for spot in self.skillFrames.keys(): if spot not in totalComboSkills: self.skillFrames[spot].hide() count = 0 for skill in totalComboSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] showIcon = skill in comboSkills or skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = 0.2 + 0.175 * count y = 1.11 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton[ 'command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5 ] count += 1 count = 0 for skill in totalActiveSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] xMod, yMod = self.ringOffset(count) xMod *= 0.9 yMod *= 0.9 showIcon = skill in activeSkills or skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = xMod + 0.53 y = yMod + 0.615 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton[ 'command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5 ] ammo = self.getAmmo(skill) if ammo != None and showIcon: self.skillFrames[skill].showQuantity = True self.skillFrames[skill].updateQuantity(ammo) count += 1 count = 0 for skill in totalPassiveSkills: skillPts = inv.getStackQuantity(skill) if skill in self.localMods: skillPts = self.localMods[skill] showIcon = skill in passiveSkills or skillPts > 0 freeLock = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): freeLock = True if self.linkedSkillIds.has_key(skill): if self.skillFrames.has_key(skill): self.skillFrames[skill].hide() skill = self.linkedSkillIds[skill] self.createFrame(skill, skillPts, amt, freeLock, showIcon) x = 0.2 + 0.175 * count y = 0.15 self.skillFrames[skill].setPos(x, 0, y) if showIcon and skillPts > 1: self.makeBoostDisplay(skill, skillPts - 1) if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(skill): self.skillFrames[skill].skillButton[ 'command'] = base.localAvatar.guiMgr.showNonPayer self.skillFrames[skill].skillButton['extraArgs'] = [ 'Restricted_Skill_' + WeaponGlobals.getSkillName(skill), 5 ] count += 1 self.dataChanged = False return
def updateSkillTray(self, rep, weaponMode, callback = None, hideFirst = True): if rep == InventoryType.MeleeRep: return None if not callback: callback = localAvatar.guiMgr.combatTray.triggerSkillTraySkill if taskMgr.hasTaskNamed('updateSkillTray'): taskMgr.remove('updateSkillTray') if self.skillTrayState and hideFirst: self.hideSkillTray() taskMgr.doMethodLater(0.75, self.updateSkillTray, 'updateSkillTray', extraArgs = [ rep, weaponMode, callback]) return None text = PLocalizer.InventoryTypeNames.get(rep, 'Unknown') for i in range(self.numberOfItems): self.tray[i + 1].destroy() self.tray = { } if self.repMeter: self.repMeter.destroy() self.rep = rep self.weaponMode = weaponMode self.callback = callback linkedSkillIds = { } linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId) for skillId in linkedSkills: realSkillId = WeaponGlobals.getLinkedSkillId(skillId) linkedSkillIds[realSkillId] = skillId skillMap = [] self.origMap = getAllSkills(self.rep, 2, wantWeaponSkill = 1) for i in range(len(self.origMap)): skillMap.append(self.origMap[i][0]) self.traySkillMap = skillMap self.numberOfItems = len(self.traySkillMap) self.skillTray.setX(0) if self.rep != InventoryType.DefenseCannonRep: self.repMeter = ReputationMeter(self.rep, width = 0.69999999999999996) self.repMeter.setScale(1.1499999999999999, 1.1499999999999999, 1.1499999999999999) self.repMeter.reparentTo(self.skillTray) self.repMeter.setCategory(self.rep) inv = base.localAvatar.getInventory() if inv is None: return None if self.repMeter: self.repMeter.update(inv.getReputation(self.rep)) x = 0.0 offset = 0.0 for i in range(self.numberOfItems): if self.origMap[i][1] == False: locked = False if locked: image = (self.SkillIcons.find('**/base'), self.SkillIcons.find('**/base_down'), self.SkillIcons.find('**/base_over')) else: image = self.SkillIcons.find('**/base') button = DirectButton(parent = self.skillTray, relief = None, state = DGG.DISABLED, image = image, image_pos = (0.0, 0.0, 0.059999999999999998), image_scale = 0.12, image_color = (0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.55000000000000004), sortOrder = 100, pos = (x, 0, -0.0)) button.setTransparency(1) button.showQuantity = False button.greyOut = -1 button.showRing = False button.skillStatus = False if locked: lock = DirectFrame(parent = button, relief = None, image = self.lockArt, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, 0.035000000000000003)) button['state'] = DGG.NORMAL button['command'] = base.localAvatar.guiMgr.showNonPayer button['extraArgs'] = [ 'Restricted_Radial_Menu', 5] self.tray[i + 1] = button x = x + 0.14999999999999999 if i < self.numberOfItems - 1: offset = offset + 0.01 self.skillTray.setX(self.skillTray.getX() - 0.074999999999999997) i < self.numberOfItems - 1 if self.origMap[i][1] == True: skillId = self.traySkillMap[i] if linkedSkillIds.has_key(skillId): skillId = linkedSkillIds[skillId] name = PLocalizer.InventoryTypeNames[skillId] hotkey = str(i + 1) totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId) timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(skillId) if not timeSpentRecharging: timeSpentRecharging = 0 if weaponMode not in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF, WeaponGlobals.DEFENSE_CANNON) and skillId in WeaponGlobals.SpecialSkills or WeaponGlobals.getSkillReputationCategoryId(skillId) not in (InventoryType.PistolRep, InventoryType.WandRep, InventoryType.CannonRep, InventoryType.GrenadeRep, InventoryType.DefenseCannonRep): showRing = True else: showRing = False locked = self.origMap[i][2] if weaponMode == WeaponGlobals.DEFENSE_CANNON: button = AmmoSkillButton(skillId, i, self.callback, 99, 0, showQuantity = True, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) else: button = SkillButton(skillId, self.callback, 0, 0, showQuantity = False, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) button.skillStatus = True if locked: button.skillButton['command'] = base.localAvatar.guiMgr.showNonPayer button.skillButton['extraArgs'] = [ 'Restricted_Radial_Menu', 5] if showRing: button.skillRing.meterFaceHalf1.setScale(0.95999999999999996) button.skillRing.meterFaceHalf2.setScale(0.95999999999999996) button.reparentTo(self.skillTray) button.setPos(x, 0, 0.070000000000000007) self.tray[i + 1] = button if weaponMode in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF): lastAmmo = localAvatar.guiMgr.combatTray.lastAmmoSkillId.get(localAvatar.currentWeaponId) if lastAmmo is not None: if lastAmmo == skillId: button.toggleButton(True) elif self.tray[1].skillStatus is True: self.tray[1].toggleButton(True) if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE): inv = localAvatar.getInventory() maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId) if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId): ammoAmt = WeaponGlobals.INF_QUANT else: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId) ammoAmt = inv.getStackQuantity(ammoInvId) ammoMax = inv.getStackLimit(ammoInvId) button.showQuantity = True button.updateQuantity(ammoAmt) x = x + 0.17000000000000001 if i < self.numberOfItems - 1: if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.skillTray.setX(self.skillTray.getX() - 0.072499999999999995) else: self.skillTray.setX(self.skillTray.getX() - 0.085000000000000006) i < self.numberOfItems - 1 currentX = self.skillTray.getX() self.skillTray.setX(currentX + float(offset)) if self.repMeter: self.repMeter.setPos(-currentX, 0.0, -0.11) self.updateSkillTrayStates() if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.setMoveUpValue(0.34499999999999997) else: self.resetMoveUpVale() self.showSkillTray()
def createHelpFrame(self, args=None): if self.helpFrame: return None inv = localAvatar.getInventory() if not inv: return None baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier( localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4.0 bonus = localAvatar.getSkillRankBonus(self.skillId) upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId) rank = localAvatar.getSkillRank(self.skillId) skillBoost = 0 if self.skillId in ItemGlobals.getLinkedSkills( localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId) skillBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, linkedSkillId) skillBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), linkedSkillId) else: skillBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, self.skillId) skillBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), self.skillId) manaCost = 0 if WeaponGlobals.getSkillTrack( self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: manaCost = WeaponGlobals.getMojoCost(self.skillId) if manaCost < 0: amt = localAvatar.getSkillRankBonus( InventoryType.StaffConservation) manaCost = min(manaCost - manaCost * amt, 1.0) damage = 0 loDamage = 0 mpDamage = 0 mpLoDamage = 0 if WeaponGlobals.getSkillTrack( self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) elif WeaponGlobals.getSkillTrack( self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: mod = (1.0 + bonus) * lvlDamageMod damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod) loDamage = damage / 2 mpDamage = int( WeaponGlobals.getAttackTargetMojo(self.skillId) * mod) mpLoDamage = mpDamage / 2 try: skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.makeHeadingString( PLocalizer.InventoryTypeNames.get(self.skillId), 2) skillType = PLocalizer.makeHeadingString(skillInfo[0], 1) except: self.notify.error('Error getting skill info for skillId %s' % self.skillId) description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: loDamage = 0 description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get(effectId)[0] if bonus: if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and rank < 5: if rank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get(effectId) if len(entry) > 1: if not damage: upgradeInfo += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn elif not self.showIcon: unlockLevel = RepChart.getSkillUnlockLevel(self.skillId) if unlockLevel > 0: upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel if self.skillId in SkillComboReq and SkillComboReq[ self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2: color = 'red' if rank == 0: color = 'red' upgradeInfo = '' description += '\n' + color + SkillComboReq[self.skillId] + '.' skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if skillInfo[4]: if bonus == 0 and upgradeAmt > 0: if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight: pass if not (self.skillId == InventoryType.CannonShoot): bonus = upgradeAmt if upgradeAmt < 1.0 and upgradeAmt > 0: bonus *= 100 if self.skillId == InventoryType.SailTreasureSense: bonus /= 2.0 elif self.skillId == InventoryType.CutlassParry: bonus += WeaponGlobals.getSubtypeParryBonus( localAvatar.currentWeaponId) if bonus: stats.append(abs(bonus)) if self.skillId == InventoryType.DollAttune: stats.append(rank) if self.skillRank: rankText = DirectFrame(parent=self, relief=None, text=PLocalizer.makeHeadingString( PLocalizer.Rank + ' %s' % (self.skillRank + skillBoost), 2), text_align=TextNode.ARight, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), pos=(0.45000000000000001, 0, 0), textMayChange=1, sortOrder=92, state=DGG.DISABLED) stats = [stat + 0.01 for stat in stats] try: pass except TypeError: self.notify.error('Error formatting skillDesc(%s): %s' % (self.skillId, stats)) helpText = DirectFrame(parent=self, relief=None, text=skillDesc % stats, text_align=TextNode.ALeft, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=17, textMayChange=1, state=DGG.DISABLED, sortOrder=91) height = -(helpText.getHeight() + 0.01) if self.lock: height = height - 0.040000000000000001 width = 0.55000000000000004 self.helpFrame = BorderFrame(parent=self, state=DGG.DISABLED, frameSize=(-0.040000000000000001, width, height, 0.050000000000000003), pos=(0, 0, -0.12), sortOrder=90) self.helpFrame.setBin('gui-popup', 0) helpText.reparentTo(self.helpFrame) if self.skillRank: rankText.reparentTo(self.helpFrame) if self.lock: self.lockedFrame = DirectFrame( parent=self.helpFrame, relief=None, pos=(0.087999999999999995, 0, height + 0.029999999999999999), image=SkillButton.SubLock, image_scale=0.13, image_pos=(-0.055, 0, 0.012999999999999999), text=PLocalizer.VR_AuthAccess, text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG13) self.notify.debug('locked!') pos = self.helpFrame.getPos(aspect2d) x = min(pos[0], base.a2dRight - width) z = max(pos[2], base.a2dBottom - height) self.helpFrame.setPos(aspect2d, x, 0, z)
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 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=self.getName(), text_scale=titleNameScale, text_fg=titleColor, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) self.bg.setColor(titleColor) tHeight = 0.070000000000000007 titleLabel.setZ(runningVertPosition) runningVertPosition -= tHeight runningSize += tHeight labels.append(titleLabel) subtitleLabel = DirectLabel(parent=self, relief=None, text='\x1slant\x1%s %s\x2' % (rarityText, 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) 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) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17499999999999999 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) infoText = PLocalizer.ItemAttackStrength % '\x1%s\x1%s\x2' % ( itemColor, ItemGlobals.getPower(itemId)) if itemType == ItemGlobals.GUN: infoText += ' %s' % PLocalizer.ItemBarrels % '\x1%s\x1%s\x2' % ( itemColor, ItemGlobals.getBarrels(itemId)) infoText += ' %s' % PLocalizer.ItemRangeStrength % '\x1%s\x1%s\x2' % ( 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.080000000000000002 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.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)): (skillId, skillBoost) = skillBoosts[i] linkedSkills = ItemGlobals.getLinkedSkills(itemId) if linkedSkills: for id in linkedSkills: if skillId == WeaponGlobals.getLinkedSkillId(id): skillId = id continue boostIcon = self.SkillIcons.find( '**/%s' % WeaponGlobals.getSkillIcon(skillId)) 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(skillId), 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(skillBoost), 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 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 if detailsHeight: currentHeight = -detailsHeight while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.20000000000000001 >= heightMax: difference = heightMax - currentHeight placement += (0.16800000000000001 / 0.20000000000000001) * difference currentHeight += difference else: placement += 0.16800000000000001 currentHeight += 0.20000000000000001 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.080000000000000002) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = 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) 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) if basePosX > 0.0: newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001 else: newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001 if basePosZ > 0.0: newPosZ = basePosZ + cellSizeZ * 0.45000000000000001 else: newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75 if detailsPos: (newPosX, newPosZ) = detailsPos self.helpFrame.setPos(newPosX, 0, newPosZ)
def showDetails(self, cell, detailsPos, detailsHeight, event = None): self.notify.debug('Item showDetails') if self.manager.heldItem and self.manager.locked and cell.isEmpty() 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 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 = 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: 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]) 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) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17499999999999999 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) infoText = PLocalizer.ItemAttackStrength % '\x001%s\x001%s\x002' % (itemColor, ItemGlobals.getPower(itemId)) if itemType == ItemGlobals.GUN: infoText += ' %s' % PLocalizer.ItemBarrels % '\x001%s\x001%s\x002' % (itemColor, ItemGlobals.getBarrels(itemId)) infoText += ' %s' % PLocalizer.ItemRangeStrength % '\x001%s\x001%s\x002' % (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.080000000000000002 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.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)): (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.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(skillId), 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(skillBoost), 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 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 if detailsHeight: currentHeight = -detailsHeight while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.20000000000000001 >= heightMax: difference = heightMax - currentHeight placement += (0.16800000000000001 / 0.20000000000000001) * difference currentHeight += difference else: placement += 0.16800000000000001 currentHeight += 0.20000000000000001 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.080000000000000002) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = 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) 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) 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 createHelpFrame(self, args = None): if self.helpFrame: return None inv = localAvatar.getInventory() if not inv: return None baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier(localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4.0 bonus = localAvatar.getSkillRankBonus(self.skillId) upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId) rank = localAvatar.getSkillRank(self.skillId) skillBoost = 0 if self.skillId in ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId) skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, linkedSkillId) skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), linkedSkillId) else: skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, self.skillId) skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), self.skillId) manaCost = 0 if WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: manaCost = WeaponGlobals.getMojoCost(self.skillId) if manaCost < 0: amt = localAvatar.getSkillRankBonus(InventoryType.StaffConservation) manaCost = min(manaCost - manaCost * amt, 1.0) damage = 0 loDamage = 0 mpDamage = 0 mpLoDamage = 0 if WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) elif WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: mod = (1.0 + bonus) * lvlDamageMod damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod) loDamage = damage / 2 mpDamage = int(WeaponGlobals.getAttackTargetMojo(self.skillId) * mod) mpLoDamage = mpDamage / 2 try: skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.makeHeadingString(PLocalizer.InventoryTypeNames.get(self.skillId), 2) skillType = PLocalizer.makeHeadingString(skillInfo[0], 1) except: self.notify.error('Error getting skill info for skillId %s' % self.skillId) description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: loDamage = 0 description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get(effectId)[0] if bonus: if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and rank < 5: if rank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get(effectId) if len(entry) > 1: if not damage: upgradeInfo += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn elif not self.showIcon: unlockLevel = RepChart.getSkillUnlockLevel(self.skillId) if unlockLevel > 0: upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel if self.skillId in SkillComboReq and SkillComboReq[self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2: color = 'red' if rank == 0: color = 'red' upgradeInfo = '' description += '\n' + color + SkillComboReq[self.skillId] + '.' skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if skillInfo[4]: if bonus == 0 and upgradeAmt > 0: if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight: pass if not (self.skillId == InventoryType.CannonShoot): bonus = upgradeAmt if upgradeAmt < 1.0 and upgradeAmt > 0: bonus *= 100 if self.skillId == InventoryType.SailTreasureSense: bonus /= 2.0 elif self.skillId == InventoryType.CutlassParry: bonus += WeaponGlobals.getSubtypeParryBonus(localAvatar.currentWeaponId) if bonus: stats.append(abs(bonus)) if self.skillId == InventoryType.DollAttune: stats.append(rank) if self.skillRank: rankText = DirectFrame(parent = self, relief = None, text = PLocalizer.makeHeadingString(PLocalizer.Rank + ' %s' % (self.skillRank + skillBoost), 2), text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), pos = (0.45000000000000001, 0, 0), textMayChange = 1, sortOrder = 92, state = DGG.DISABLED) stats = [stat + 0.01 for stat in stats] try: pass except TypeError: self.notify.error('Error formatting skillDesc(%s): %s' % (self.skillId, stats)) helpText = DirectFrame(parent = self, relief = None, text = skillDesc % stats, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 17, textMayChange = 1, state = DGG.DISABLED, sortOrder = 91) height = -(helpText.getHeight() + 0.01) if self.lock: height = height - 0.040000000000000001 width = 0.55000000000000004 self.helpFrame = BorderFrame(parent = self, state = DGG.DISABLED, frameSize = (-0.040000000000000001, width, height, 0.050000000000000003), pos = (0, 0, -0.12), sortOrder = 90) self.helpFrame.setBin('gui-popup', 0) helpText.reparentTo(self.helpFrame) if self.skillRank: rankText.reparentTo(self.helpFrame) if self.lock: self.lockedFrame = DirectFrame(parent = self.helpFrame, relief = None, pos = (0.087999999999999995, 0, height + 0.029999999999999999), image = SkillButton.SubLock, image_scale = 0.13, image_pos = (-0.055, 0, 0.012999999999999999), text = PLocalizer.VR_AuthAccess, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG13) self.notify.debug('locked!') pos = self.helpFrame.getPos(aspect2d) x = min(pos[0], base.a2dRight - width) z = max(pos[2], base.a2dBottom - height) self.helpFrame.setPos(aspect2d, x, 0, z)