コード例 #1
0
ファイル: SimpleStoreItem.py プロジェクト: TTGhost/POTCOR-src
 def __init__(self, uid):
     self.uid = uid
     self.itemName = PLocalizer.getItemName(uid)
     self.shortDesc = PLocalizer.getItemName(uid)
     self.longDesc = PLocalizer.getItemFlavorText(uid)
     self.text = None
     self.modelId = None
     self.texId = None
     self.colorId = 0
     self.holidayId = None
     self.icon = None
     self.iconScale = 1.0
     self.iconHpr = (0, 0, 0)
     if self.checkStackable():
         self.quantity = EconomyGlobals.getItemQuantity(self.uid)
     else:
         self.quantity = 1
コード例 #2
0
 def __init__(self, uid):
     self.uid = uid
     self.itemName = PLocalizer.getItemName(uid)
     self.shortDesc = PLocalizer.getItemName(uid)
     self.longDesc = PLocalizer.getItemFlavorText(uid)
     self.text = None
     self.modelId = None
     self.texId = None
     self.colorId = 0
     self.holidayId = None
     self.icon = None
     self.iconScale = 1.0
     self.iconHpr = (0, 0, 0)
     if self.checkStackable():
         self.quantity = EconomyGlobals.getItemQuantity(self.uid)
     else:
         self.quantity = 1
コード例 #3
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     inv = localAvatar.getInventory()
     if not inv:
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
     border = self.SkillIcons.find('**/base')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\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)
コード例 #4
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
     border = self.SkillIcons.find('**/base')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x01slant\x01%s %s\x02' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     itemType = ItemGlobals.getType(itemId)
     itemSubtype = ItemGlobals.getSubtype(itemId)
     model = ItemGlobals.getModel(itemId)
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     if itemSubtype == ItemGlobals.POTION_BUFF:
         self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)), pos = (0.0, 2.5, 0.0))
     elif model:
         self.realItem = loader.loadModel('models/inventory/' + model, okMissing = True)
         if not self.realItem:
             self.realItem = loader.loadModel('models/handheld/' + model)
         
         if self.realItem:
             posHpr = ItemGlobals.getModelPosHpr(model)
             if posHpr:
                 self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                 self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
             else:
                 self.realItem.setPos(0.0, 2.5, -0.40000000000000002)
                 self.realItem.setHpr(45, 0, 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)
     if ItemGlobals.getSubtype(itemId) == 30:
         duration = PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
         if duration >= 3600:
             duration = duration / 3600
             if duration == 1:
                 units = PLocalizer.Hour
             else:
                 units = PLocalizer.Hours
         elif duration >= 60:
             duration = duration / 60
             if duration == 1:
                 units = PLocalizer.Minute
             else:
                 units = PLocalizer.Minutes
         else:
             units = PLocalizer.Seconds
         potency = PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
         data = {
             'pot': int(potency * 100),
             'dur': int(duration),
             'unit': units }
         description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(itemId)].safe_substitute(data)
     else:
         description = PLocalizer.getItemFlavorText(itemId)
     if description != '':
         descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.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)
     
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     useLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.RightClickPotion, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     uHeight = useLabel.getHeight()
     runningVertPosition -= uHeight
     runningSize += uHeight
     labels.append(useLabel)
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.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)
     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)
コード例 #5
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

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

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

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

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

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

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

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

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

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

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

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

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

        self.helpFrame.setPos(newPosX, 0, newPosZ)
コード例 #6
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     typeText = PLocalizer.getJewelryTypeName(ItemGlobals.getType(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x001slant\x001%s %s\x002' % (rarityText, typeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     gender = localAvatar.style.gender
     dna = HumanDNA.HumanDNA(gender)
     dna.copy(localAvatar.style)
     bodyShape = localAvatar.style.getBodyShape()
     bodyHeight = localAvatar.style.getBodyHeight()
     bodyOffset = 0.5
     browOffset = 0
     earOffset = 0
     noseOffset = 0
     mouthOffset = 0
     handOffset = 0
     if bodyShape == 0:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.75
             earOffset = 0.65000000000000002
             noseOffset = 0.69999999999999996
             mouthOffset = 0.75
             handOffset = 0.40000000000000002
         elif gender == 'f':
             browOffset = 0.55000000000000004
             earOffset = 0.55000000000000004
             noseOffset = 0.45000000000000001
             mouthOffset = 0.65000000000000002
             handOffset = 0.29999999999999999
         
     elif bodyShape == 1:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.20000000000000001
             earOffset = 0.20000000000000001
             noseOffset = 0.10000000000000001
             mouthOffset = 0.20000000000000001
             handOffset = 0.20000000000000001
         elif gender == 'f':
             browOffset = 0.5
             earOffset = 0.5
             noseOffset = 0.40000000000000002
             mouthOffset = 0.5
             handOffset = 0.20000000000000001
         
     elif bodyShape == 2:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = -0.10000000000000001
             earOffset = -0.10000000000000001
             noseOffset = -0.20000000000000001
             mouthOffset = -0.10000000000000001
             handOffset = -0.10000000000000001
         
     elif bodyShape == 3:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.20000000000000001
             earOffset = 0.20000000000000001
             noseOffset = 0.050000000000000003
             mouthOffset = 0.20000000000000001
             handOffset = 0.20000000000000001
         elif gender == 'f':
             browOffset = -0.40000000000000002
             earOffset = -0.40000000000000002
             noseOffset = -0.45000000000000001
             mouthOffset = -0.29999999999999999
             handOffset = -0.20000000000000001
         
     elif bodyShape == 4:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.20000000000000001
             earOffset = -0.20000000000000001
             noseOffset = -0.29999999999999999
             mouthOffset = -0.14999999999999999
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = 0.0
             mouthOffset = 0.10000000000000001
             handOffset = 0.0
         
     elif bodyShape == 5:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = -0.050000000000000003
             earOffset = -0.10000000000000001
             noseOffset = -0.14999999999999999
             mouthOffset = -0.050000000000000003
             handOffset = -0.10000000000000001
         
     elif bodyShape == 6:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = 0.40000000000000002
             earOffset = 0.40000000000000002
             noseOffset = 0.25
             mouthOffset = 0.40000000000000002
             handOffset = 0.10000000000000001
         
     elif bodyShape == 7:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = 0.10000000000000001
             earOffset = 0.10000000000000001
             noseOffset = -0.050000000000000003
             mouthOffset = 0.10000000000000001
             handOffset = 0.10000000000000001
         elif gender == 'f':
             browOffset = 0.0
             earOffset = -0.050000000000000003
             noseOffset = -0.10000000000000001
             mouthOffset = 0.0
             handOffset = -0.050000000000000003
         
     elif bodyShape == 8:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.10000000000000001
             earOffset = -0.10000000000000001
             noseOffset = -0.20000000000000001
             mouthOffset = -0.050000000000000003
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = -0.14999999999999999
             earOffset = -0.14999999999999999
             noseOffset = -0.25
             mouthOffset = -0.14999999999999999
             handOffset = -0.10000000000000001
         
     elif bodyShape == 9:
         bodyOffset = 0.5
         if gender == 'm':
             browOffset = -0.20000000000000001
             earOffset = -0.20000000000000001
             noseOffset = -0.29999999999999999
             mouthOffset = -0.10000000000000001
             handOffset = -0.050000000000000003
         elif gender == 'f':
             browOffset = -0.34999999999999998
             earOffset = -0.34999999999999998
             noseOffset = -0.45000000000000001
             mouthOffset = -0.34999999999999998
             handOffset = -0.20000000000000001
         
     
     m = Mat4(Mat4.identMat())
     itemType = ItemGlobals.getType(itemId)
     if itemType == ItemGlobals.BROW:
         jewelType = JewelryGlobals.LBROW
     elif itemType == ItemGlobals.EAR:
         jewelType = JewelryGlobals.LEAR
     elif itemType == ItemGlobals.NOSE:
         jewelType = JewelryGlobals.NOSE
     elif itemType == ItemGlobals.MOUTH:
         jewelType = JewelryGlobals.MOUTH
     elif itemType == ItemGlobals.HAND:
         jewelType = JewelryGlobals.LHAND
     
     primaryColor = ItemGlobals.getPrimaryColor(itemId)
     secondaryColor = ItemGlobals.getSecondaryColor(itemId)
     if localAvatar.style.gender == 'm':
         maleModelId = ItemGlobals.getMaleModelId(itemId)
         if maleModelId:
             jewelId = maleModelId
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'm'
         else:
             jewelId = ItemGlobals.getFemaleModelId(itemId)
             dna = HumanDNA.HumanDNA('f')
             gender = 'f'
     else:
         femaleModelId = ItemGlobals.getFemaleModelId(itemId)
         if femaleModelId:
             jewelId = femaleModelId
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'f'
         else:
             jewelId = ItemGlobals.getMaleModelId(itemId)
             dna = HumanDNA.HumanDNA('m')
             gender = 'm'
     if jewelType == JewelryGlobals.LBROW:
         dna.setJewelryZone3(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.LEAR:
         dna.setJewelryZone1(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.NOSE:
         dna.setJewelryZone5(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.MOUTH:
         dna.setJewelryZone6(jewelId, primaryColor, secondaryColor)
     elif jewelType == JewelryGlobals.LHAND:
         dna.setJewelryZone7(jewelId, primaryColor, secondaryColor)
     
     dna.setClothesHat(0, 0)
     self.displayHuman.setDNAString(dna)
     self.displayHuman.generateHuman(gender, self.masterHuman)
     self.displayHuman.stopBlink()
     self.displayHuman.pose('idle', 1)
     lodNode = self.displayHuman.find('**/+LODNode').node()
     lodNode.forceSwitch(lodNode.getHighestSwitch())
     if jewelType == JewelryGlobals.LBROW:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('trs_right_eyebrow').getNetTransform(m)
         rightEyeHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetX = 0.40000000000000002
             offsetZ = -rightEyeHeight + browOffset - bodyHeight * 1.0
             offsetY = 0.25 + bodyOffset
         else:
             offsetX = 0.29999999999999999
             offsetZ = -rightEyeHeight * 0.98999999999999999 + browOffset - bodyHeight * 1.0
             offsetY = 0.14999999999999999 + bodyOffset
         offsetH = -240
     elif jewelType == JewelryGlobals.LEAR:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_trs_left_ear').getNetTransform(m)
         leftEarHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -leftEarHeight + earOffset - bodyHeight * 1.0
             offsetY = 0.40000000000000002 + bodyOffset
             offsetX = 0.14999999999999999
         else:
             offsetZ = -leftEarHeight * 0.98999999999999999 + earOffset - bodyHeight * 1.0
             offsetY = 0.29999999999999999 + bodyOffset
             offsetX = 0.040000000000000001
         offsetH = -250
     elif jewelType == JewelryGlobals.NOSE:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_trs_mid_nose_bot').getNetTransform(m)
         noseHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -noseHeight + 0.089999999999999997 + noseOffset - bodyHeight * 0.80000000000000004
             offsetY = 0.45000000000000001 + bodyOffset
         else:
             offsetZ = -noseHeight + 0.10000000000000001 + noseOffset - bodyHeight * 0.80000000000000004
             offsetY = 0.40000000000000002 + bodyOffset
         offsetX = 0.059999999999999998
         offsetH = 180
     elif jewelType == JewelryGlobals.MOUTH:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('trs_lips_top').getNetTransform(m)
         mouthHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -mouthHeight + 0.02 + mouthOffset - bodyHeight * 1.1000000000000001
         offsetY = 0.59999999999999998 + bodyOffset
         offsetX = 0.080000000000000002
         offsetH = 180
     elif jewelType == JewelryGlobals.LHAND:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_left_index01').getNetTransform(m)
         leftIndexHeight = TransformState.makeMat(m).getPos().getZ()
         if gender == 'f':
             offsetZ = -leftIndexHeight + 0.050000000000000003 + handOffset - bodyHeight * 0.5
             offsetX = -0.69999999999999996
             offsetY = 1.25 + bodyOffset
         else:
             offsetZ = -leftIndexHeight + handOffset - bodyHeight * 0.5
             if bodyShape == 4:
                 offsetX = -1.0
                 offsetY = 1.75 + bodyOffset
             elif bodyShape == 3:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             elif bodyShape == 1:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             elif bodyShape == 0:
                 offsetX = -0.69999999999999996
                 offsetY = 1.25 + bodyOffset
             else:
                 offsetX = -0.80000000000000004
                 offsetY = 1.25 + bodyOffset
         offsetH = 160
     else:
         offsetZ = 0.0
         offsetY = 0.0
         offsetX = 0.0
         offsetH = 0
     self.displayHuman.setY(offsetY)
     self.displayHuman.setZ(offsetZ)
     self.displayHuman.setX(offsetX)
     self.displayHuman.setH(offsetH)
     self.displayHuman.reparentTo(self.portraitSceneGraph)
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     itemCost = int(ItemGlobals.getGoldCost(itemId))
     if self.cell and self.cell.container:
         itemCost = int(itemCost * self.cell.container.getItemPriceMult())
     
     goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale))
     labels.append(goldLabel)
     descriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemFlavorText(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_fg = PiratesGuiGlobals.TextFG0, text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     dHeight = descriptionLabel.getHeight() + 0.02
     runningVertPosition -= dHeight
     runningSize += dHeight
     labels.append(descriptionLabel)
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.080000000000000002)
     topPanel.reparentTo(self.helpFrame)
     middlePanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/middle_panel').copyTo(middlePanel)
     middlePanel.setScale(0.080000000000000002)
     middlePanel.reparentTo(self.helpFrame)
     placement = 0
     i = 0
     heightMax = -0.080000000000000002
     currentHeight = runningVertPosition
     if detailsHeight:
         currentHeight = -detailsHeight
     
     while currentHeight < heightMax:
         middlePanel = panels.attachNewNode('middlePanel%s' % 1)
         detailGui.find('**/middle_panel').copyTo(middlePanel)
         middlePanel.setScale(0.080000000000000002)
         middlePanel.reparentTo(self.helpFrame)
         if currentHeight + 0.20000000000000001 >= heightMax:
             difference = heightMax - currentHeight
             placement += (0.16800000000000001 / 0.20000000000000001) * difference
             currentHeight += difference
         else:
             placement += 0.16800000000000001
             currentHeight += 0.20000000000000001
         middlePanel.setZ(-placement)
         i += 1
     bottomPanel = panels.attachNewNode('bottomPanel')
     detailGui.find('**/bottom_panel').copyTo(bottomPanel)
     bottomPanel.setScale(0.080000000000000002)
     bottomPanel.setZ(-placement)
     bottomPanel.reparentTo(self.helpFrame)
     colorPanel = self.helpFrame.attachNewNode('colorPanel')
     detailGui.find('**/color').copyTo(colorPanel)
     colorPanel.setScale(0.080000000000000002)
     colorPanel.setColor(titleColor)
     colorPanel.reparentTo(self.helpFrame)
     lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
     detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
     lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007)
     lineBreakTopPanel.setZ(0.0080000000000000002)
     lineBreakTopPanel.reparentTo(self.helpFrame)
     panels.flattenStrong()
     self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin)
     totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
     for label in labels:
         label.reparentTo(self.helpFrame)
     
     if basePosX > 0.0:
         newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
     else:
         newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
     if basePosZ > 0.0:
         newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
     else:
         newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
     if detailsPos:
         (newPosX, newPosZ) = detailsPos
     
     self.helpFrame.setPos(newPosX, 0, newPosZ)
コード例 #7
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.helpFrame.setPos(newPosX, 0, newPosZ)
コード例 #8
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem or self.manager.locked or cell.isEmpty(
        ) or self.isEmpty() or not self.itemTuple:
            self.notify.debug(' early exit')
            return
        inv = localAvatar.getInventory()
        if not inv:
            return
        itemId = self.getId()
        self.helpFrame = DirectFrame(parent=self.manager,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     sortOrder=1)
        self.helpFrame.setBin('gui-popup', -5)
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        topGui = loader.loadModel('models/gui/toplevel_gui')
        coinImage = topGui.find('**/treasure_w_coin*')
        self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        self.BuffIcons = loader.loadModel('models/textureCards/buff_icons')
        border = self.SkillIcons.find('**/base')
        halfWidth = 0.3
        halfHeight = 0.2
        basePosX = cell.getX(aspect2d)
        basePosZ = cell.getZ(aspect2d)
        cellSizeX = 0.0
        cellSizeZ = 0.0
        if cell:
            cellSizeX = cell.cellSizeX
            cellSizeZ = cell.cellSizeZ
        textScale = PiratesGuiGlobals.TextScaleMed
        titleScale = PiratesGuiGlobals.TextScaleTitleSmall
        if len(self.getName()) >= 30:
            titleNameScale = PiratesGuiGlobals.TextScaleLarge
        else:
            titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
        subtitleScale = PiratesGuiGlobals.TextScaleMed
        iconScalar = 1.5
        borderScaler = 0.25
        splitHeight = 0.01
        vMargin = 0.03
        runningVertPosition = 0.3
        runningSize = 0.0
        labels = []
        titleColor = PiratesGuiGlobals.TextFG6
        itemColor = 'itemRed'
        rarity = ItemGlobals.getRarity(itemId)
        rarityText = PLocalizer.getItemRarityName(rarity)
        subtypeText = PLocalizer.getItemSubtypeName(
            ItemGlobals.getSubtype(itemId))
        if rarity == ItemGlobals.CRUDE:
            titleColor = PiratesGuiGlobals.TextFG24
            itemColor = 'itemBrown'
        else:
            if rarity == ItemGlobals.COMMON:
                titleColor = PiratesGuiGlobals.TextFG13
                itemColor = 'itemYellow'
            else:
                if rarity == ItemGlobals.RARE:
                    titleColor = PiratesGuiGlobals.TextFG4
                    itemColor = 'itemGreen'
                else:
                    if rarity == ItemGlobals.FAMED:
                        titleColor = PiratesGuiGlobals.TextFG5
                        itemColor = 'itemBlue'
        titleLabel = DirectLabel(parent=self,
                                 relief=None,
                                 text=self.getName(),
                                 text_scale=titleNameScale,
                                 text_fg=titleColor,
                                 text_shadow=PiratesGuiGlobals.TextShadow,
                                 text_align=TextNode.ACenter,
                                 pos=(0.0, 0.0, runningVertPosition),
                                 text_pos=(0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.07
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='\x01slant\x01%s %s\x02' %
                                    (rarityText, subtypeText),
                                    text_scale=subtitleScale,
                                    text_fg=PiratesGuiGlobals.TextFG2,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
        subtHeight = 0.05
        subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
        runningVertPosition -= subtHeight
        runningSize += subtHeight
        labels.append(subtitleLabel)
        itemType = ItemGlobals.getType(itemId)
        itemSubtype = ItemGlobals.getSubtype(itemId)
        model = ItemGlobals.getModel(itemId)
        if model:
            if itemType == ItemGlobals.GRENADE:
                self.realItem = loader.loadModel('models/ammunition/' + model)
            else:
                self.realItem = loader.loadModel('models/handheld/' + model)
            if self.realItem:
                spinBlur = self.realItem.find('**/motion_blur')
                if spinBlur:
                    spinBlur.hide()
                if itemSubtype == ItemGlobals.MUSKET:
                    bayonetPart = self.realItem.find('**/bayonet')
                    if bayonetPart:
                        bayonetPart.stash()
                posHpr = ItemGlobals.getModelPosHpr(model)
                if posHpr:
                    self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                    self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
                else:
                    if itemType == ItemGlobals.SWORD:
                        self.realItem.setPos(-1.5, 3.0, -0.3)
                        self.realItem.setHpr(90, 170, -90)
                    else:
                        if itemSubtype in (ItemGlobals.MUSKET,
                                           ItemGlobals.BAYONET):
                            self.realItem.setPos(-1.2, 3.0, -0.1)
                            self.realItem.setHpr(0, 135, 10)
                        else:
                            if itemSubtype == ItemGlobals.BLUNDERBUSS:
                                self.realItem.setPos(-0.3, 2.0, 0.0)
                                self.realItem.setHpr(0, 90, 0)
                            else:
                                if itemType == ItemGlobals.GUN:
                                    self.realItem.setPos(-0.5, 2.0, -0.2)
                                    self.realItem.setHpr(0, 90, 0)
                                else:
                                    if itemType == ItemGlobals.DOLL:
                                        self.realItem.setPos(0.0, 1.9, -0.1)
                                        self.realItem.setHpr(0, 90, 180)
                                    else:
                                        if itemType == ItemGlobals.DAGGER:
                                            self.realItem.setPos(
                                                -1.0, 2.0, -0.3)
                                            self.realItem.setHpr(90, 170, -90)
                                        else:
                                            if itemType == ItemGlobals.GRENADE:
                                                self.realItem.setPos(
                                                    0.0, 3.5, -0.2)
                                                self.realItem.setHpr(0, 0, 0)
                                            else:
                                                if itemType == ItemGlobals.STAFF:
                                                    self.realItem.setPos(
                                                        -0.4, 3.0, -0.3)
                                                    self.realItem.setHpr(
                                                        -90, 15, -90)
                self.realItem.reparentTo(self.portraitSceneGraph)
        iHeight = 0.175
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.06)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        itemCost = int(ItemGlobals.getGoldCost(itemId))
        if self.cell:
            if self.cell.container:
                itemCost = int(itemCost *
                               self.cell.container.getItemPriceMult())
            goldLabel = DirectLabel(parent=self,
                                    relief=None,
                                    image=coinImage,
                                    image_scale=0.12,
                                    image_pos=Vec3(0.025, 0, -0.02),
                                    text=str(itemCost),
                                    text_scale=subtitleScale,
                                    text_align=TextNode.ARight,
                                    text_fg=PiratesGuiGlobals.TextFG1,
                                    text_shadow=PiratesGuiGlobals.TextShadow,
                                    pos=(halfWidth - 0.05, 0.0,
                                         runningVertPosition + 0.08),
                                    text_pos=(0.0, -textScale))
            labels.append(goldLabel)
            infoText = PLocalizer.ItemAttackStrength % (
                '\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getPower(itemId)))
            if itemType == ItemGlobals.GUN:
                infoText += '     %s' % (
                    PLocalizer.ItemBarrels %
                    ('\x01%s\x01%s\x02' %
                     (itemColor, ItemGlobals.getBarrels(itemId))))
                infoText += '     %s' % (
                    PLocalizer.ItemRangeStrength %
                    ('\x01%s\x01%s\x02' %
                     (itemColor,
                      PLocalizer.getItemRangeName(
                          WeaponGlobals.getRange(itemId)))))
            infoLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text=infoText,
                                    text_scale=textScale,
                                    text_align=TextNode.ACenter,
                                    pos=(0.0, 0.0, runningVertPosition),
                                    text_pos=(0.0, -textScale))
            iHeight = 0.08
            runningVertPosition -= iHeight
            runningSize += iHeight
            labels.append(infoLabel)
            specialAttack = ItemGlobals.getSpecialAttack(itemId)
            if specialAttack:
                attackIcon = self.SkillIcons.find(
                    '**/%s' % WeaponGlobals.getSkillIcon(specialAttack))
                specialAttackNameLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    image=border,
                    image_scale=0.1,
                    geom=attackIcon,
                    geom_scale=0.1,
                    image_pos=(-0.07, 0.0, -0.05),
                    geom_pos=(-0.07, 0.0, -0.05),
                    text=PLocalizer.getInventoryTypeName(specialAttack),
                    text_scale=PiratesGuiGlobals.TextScaleLarge,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    text_fg=titleColor,
                    text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                specialAttackRankLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.ItemRank %
                    ItemGlobals.getSpecialAttackRank(itemId),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ARight,
                    pos=(halfWidth - textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                specialAttackType = WeaponGlobals.getSkillTrack(specialAttack)
                if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX:
                    specialAttackTypeText = PLocalizer.BreakAttackSkill
                else:
                    if specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX:
                        specialAttackTypeText = PLocalizer.DefenseSkill
                    else:
                        specialAttackTypeText = PLocalizer.WeaponSkill
                specialAttackTypeLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=specialAttackTypeText,
                    text_scale=0.0335,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition -
                         PiratesGuiGlobals.TextScaleLarge),
                    text_pos=(0.0, -textScale))
                specialAttackInfo = PLocalizer.SkillDescriptions.get(
                    specialAttack)
                specialAttackDescriptionText = specialAttackInfo[1]
                specialAttackDescriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=specialAttackDescriptionText,
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition -
                         (specialAttackNameLabel.getHeight() +
                          specialAttackTypeLabel.getHeight() - 0.06)),
                    text_pos=(0.0, -textScale))
                saHeight = specialAttackNameLabel.getHeight(
                ) + specialAttackTypeLabel.getHeight(
                ) + specialAttackDescriptionLabel.getHeight() - 0.04
                runningVertPosition -= saHeight
                runningSize += saHeight
                labels.append(specialAttackNameLabel)
                labels.append(specialAttackRankLabel)
                labels.append(specialAttackTypeLabel)
                labels.append(specialAttackDescriptionLabel)
            attributes = ItemGlobals.getAttributes(itemId)
            for i in range(0, len(attributes)):
                attributeIcon = self.SkillIcons.find(
                    '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0]))
                if not attributeIcon:
                    attributeIcon = self.BuffIcons.find(
                        '**/%s' %
                        ItemGlobals.getAttributeIcon(attributes[i][0]))
                attributeNameLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    image=border,
                    image_scale=0.05,
                    geom=attributeIcon,
                    geom_scale=0.05,
                    image_pos=(-0.07, 0.0, -0.03),
                    geom_pos=(-0.07, 0.0, -0.03),
                    text=PLocalizer.getItemAttributeName(attributes[i][0]),
                    text_scale=PiratesGuiGlobals.TextScaleLarge,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    text_fg=titleColor,
                    text_font=PiratesGlobals.getInterfaceOutlineFont(),
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                attributeRankLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.ItemRank % attributes[i][1],
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale),
                    text_align=TextNode.ARight,
                    pos=(halfWidth - textScale * 0.5, 0.0,
                         runningVertPosition),
                    text_pos=(0.0, -textScale))
                if attributeNameLabel.getHeight() > 0.075:
                    attributeNameSpace = 0.08
                else:
                    attributeNameSpace = PiratesGuiGlobals.TextScaleLarge
                attributeDescriptionLabel = DirectLabel(
                    parent=self,
                    relief=None,
                    text=PLocalizer.getItemAttributeDescription(
                        attributes[i][0]),
                    text_scale=textScale,
                    text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale),
                    text_align=TextNode.ALeft,
                    pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0,
                         runningVertPosition - attributeNameSpace),
                    text_pos=(0.0, -textScale))
                aHeight = attributeNameLabel.getHeight(
                ) + attributeDescriptionLabel.getHeight()
                runningVertPosition -= aHeight + splitHeight
                runningSize += aHeight + splitHeight
                labels.append(attributeNameLabel)
                labels.append(attributeRankLabel)
                labels.append(attributeDescriptionLabel)

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

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

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

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

            if basePosX > 0.0:
                newPosX = basePosX - (halfWidth + cellSizeX * 0.45)
            else:
                newPosX = basePosX + (halfWidth + cellSizeX * 0.45)
            newPosZ = basePosZ > 0.0 and basePosZ + cellSizeZ * 0.45
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
コード例 #9
0
    def showDetails(self, cell, detailsPos, detailsHeight, event=None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty(
        ) or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

        self.displayHuman.setDNAString(dna)
        self.displayHuman.generateHuman(gender, self.masterHuman)
        self.displayHuman.stopBlink()
        self.displayHuman.pose('idle', 1)
        lodNode = self.displayHuman.find('**/+LODNode').node()
        lodNode.forceSwitch(lodNode.getHighestSwitch())
        self.displayHuman.reparentTo(self.portraitSceneGraph)
        if tattooType == TattooGlobals.ZONE1:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_spine03').getNetTransform(m)
            spine3Height = TransformState.makeMat(m).getPos().getZ()
            offsetZ = -spine3Height + chestOffset - bodyHeight * 1.2
            offsetX = 0.0
            offsetY = 3.25 + bodyOffset
            offsetH = 180
        elif tattooType == TattooGlobals.ZONE2:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_left_shoulder').getNetTransform(m)
            leftShoulderHeight = TransformState.makeMat(m).getPos().getZ()
            if gender == 'f':
                offsetZ = -leftShoulderHeight + 1.2 + armOffset - bodyHeight * 0.80000000000000004
                offsetX = 0.0
                offsetY = 2.0 + bodyOffset
            else:
                offsetZ = -leftShoulderHeight + 0.45000000000000001 + armOffset - bodyHeight * 0.80000000000000004
                if bodyShape == 4:
                    offsetY = 2.5 + bodyOffset
                else:
                    offsetY = 2.0 + bodyOffset
                offsetX = -0.20000000000000001
            offsetH = 105
        elif tattooType == TattooGlobals.ZONE4:
            self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_head01').getNetTransform(m)
            headHeight = TransformState.makeMat(m).getPos().getZ()
            offsetZ = (-headHeight - 0.10000000000000001) + headOffset - bodyHeight * 1.1000000000000001
            offsetX = 0.0
            offsetY = 1.5 + bodyOffset
            offsetH = 180
        else:
            offsetZ = 0
            offsetY = 0
            offsetX = 0
            offsetH = 0
        self.displayHuman.setY(offsetY)
        self.displayHuman.setZ(offsetZ)
        self.displayHuman.setX(offsetX)
        self.displayHuman.setH(offsetH)
        iHeight = 0.17999999999999999
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        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)
        descriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemFlavorText(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_fg = PiratesGuiGlobals.TextFG0, text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
        dHeight = descriptionLabel.getHeight() + 0.02
        runningVertPosition -= dHeight
        runningSize += dHeight
        labels.append(descriptionLabel)
        if not Freebooter.getPaidStatus(localAvatar.getDoId()):
            if rarity != ItemGlobals.CRUDE:
                unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
                uHeight = unlimitedLabel.getHeight()
                runningVertPosition -= uHeight
                runningSize += uHeight
                labels.append(unlimitedLabel)


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

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

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

        self.helpFrame.setPos(newPosX, 0, newPosZ)
コード例 #11
0
 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

        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)
        skillIcons = loader.loadModel('models/textureCards/skillIcons')
        if itemSubtype == ItemGlobals.POTION_BUFF:
            self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)), pos = (0.0, 2.5, 0.0))
        elif model:
            self.realItem = loader.loadModel('models/inventory/' + model, okMissing = True)
            if not self.realItem:
                self.realItem = loader.loadModel('models/handheld/' + model)

            if self.realItem:
                posHpr = ItemGlobals.getModelPosHpr(model)
                if posHpr:
                    self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2])
                    self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5])
                else:
                    self.realItem.setPos(0.0, 2.5, -0.40000000000000002)
                    self.realItem.setHpr(45, 0, 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)
        if ItemGlobals.getSubtype(itemId) == 30:
            duration = PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
            if duration >= 3600:
                duration = duration / 3600
                if duration == 1:
                    units = PLocalizer.Hour
                else:
                    units = PLocalizer.Hours
            elif duration >= 60:
                duration = duration / 60
                if duration == 1:
                    units = PLocalizer.Minute
                else:
                    units = PLocalizer.Minutes
            else:
                units = PLocalizer.Seconds
            potency = PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId)))
            data = {
                'pot': int(potency * 100),
                'dur': int(duration),
                'unit': units }
            description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(itemId)].safe_substitute(data)
        else:
            description = PLocalizer.getItemFlavorText(itemId)
        if description != '':
            descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.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)

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


        runningVertPosition -= 0.02
        runningSize += 0.02
        useLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.RightClickPotion, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
        uHeight = useLabel.getHeight()
        runningVertPosition -= uHeight
        runningSize += uHeight
        labels.append(useLabel)
        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.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)
        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)
コード例 #13
0
 def showDetails(self, cell, detailsPos, detailsHeight, event = None):
     self.notify.debug('Item showDetails')
     if self.manager.heldItem and self.manager.locked and cell.isEmpty() or not (self.itemTuple):
         self.notify.debug(' early exit')
         return None
     
     itemId = self.getId()
     self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1)
     self.helpFrame.setBin('gui-popup', -5)
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     topGui = loader.loadModel('models/gui/toplevel_gui')
     coinImage = topGui.find('**/treasure_w_coin*')
     halfWidth = 0.29999999999999999
     halfHeight = 0.20000000000000001
     basePosX = cell.getX(aspect2d)
     basePosZ = cell.getZ(aspect2d)
     cellSizeX = 0.0
     cellSizeZ = 0.0
     if cell:
         cellSizeX = cell.cellSizeX
         cellSizeZ = cell.cellSizeZ
     
     textScale = PiratesGuiGlobals.TextScaleMed
     titleScale = PiratesGuiGlobals.TextScaleTitleSmall
     if len(self.getName()) >= 30:
         titleNameScale = PiratesGuiGlobals.TextScaleLarge
     else:
         titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge
     subtitleScale = PiratesGuiGlobals.TextScaleMed
     iconScalar = 1.5
     borderScaler = 0.25
     splitHeight = 0.01
     vMargin = 0.029999999999999999
     runningVertPosition = 0.29999999999999999
     runningSize = 0.0
     labels = []
     titleColor = PiratesGuiGlobals.TextFG6
     rarity = ItemGlobals.getRarity(itemId)
     rarityText = PLocalizer.getItemRarityName(rarity)
     typeText = ClothingGlobals.getClothingTypeName(ItemGlobals.getType(itemId))
     if rarity == ItemGlobals.CRUDE:
         titleColor = PiratesGuiGlobals.TextFG24
     elif rarity == ItemGlobals.COMMON:
         titleColor = PiratesGuiGlobals.TextFG13
     elif rarity == ItemGlobals.RARE:
         titleColor = PiratesGuiGlobals.TextFG4
     elif rarity == ItemGlobals.FAMED:
         titleColor = PiratesGuiGlobals.TextFG5
     
     titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     self.bg.setColor(titleColor)
     tHeight = 0.070000000000000007
     titleLabel.setZ(runningVertPosition)
     runningVertPosition -= tHeight
     runningSize += tHeight
     labels.append(titleLabel)
     subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x001slant\x001%s %s\x002' % (rarityText, typeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     subtHeight = 0.050000000000000003
     subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition)
     runningVertPosition -= subtHeight
     runningSize += subtHeight
     labels.append(subtitleLabel)
     clothingType = ItemGlobals.getType(itemId)
     if localAvatar.style.getGender() == 'm':
         maleModelId = ItemGlobals.getMaleModelId(itemId)
         if maleModelId != -1:
             modelId = maleModelId
             texId = ItemGlobals.getMaleTextureId(itemId)
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'm'
         else:
             modelId = ItemGlobals.getFemaleModelId(itemId)
             texId = ItemGlobals.getFemaleTextureId(itemId)
             dna = HumanDNA.HumanDNA('f')
             gender = 'f'
     else:
         femaleModelId = ItemGlobals.getFemaleModelId(itemId)
         if femaleModelId != -1:
             modelId = femaleModelId
             texId = ItemGlobals.getFemaleTextureId(itemId)
             dna = HumanDNA.HumanDNA(localAvatar.style.gender)
             dna.copy(localAvatar.style)
             gender = 'f'
         else:
             modelId = ItemGlobals.getMaleModelId(itemId)
             texId = ItemGlobals.getMaleTextureId(itemId)
             dna = HumanDNA.HumanDNA('m')
             gender = 'm'
     bodyShape = localAvatar.style.getBodyShape()
     bodyHeight = localAvatar.style.getBodyHeight()
     bodyOffset = 0.5
     headOffset = 0
     topOffset = 0
     pantOffset = 0
     beltOffset = 0
     shoeOffset = 0
     if bodyShape == 0:
         bodyOffset = 1
         headOffset = 0.69999999999999996
         topOffset = 0.69999999999999996
         pantOffset = 0.20000000000000001
         beltOffset = 0.5
     elif bodyShape == 1:
         bodyOffset = 0
         if gender == 'm':
             headOffset = -0.10000000000000001
             beltOffset = 0.10000000000000001
             shoeOffset = 0.10000000000000001
         elif gender == 'f':
             headOffset = 0.59999999999999998
             topOffset = 0.40000000000000002
             beltOffset = 0.40000000000000002
             shoeOffset = 0.10000000000000001
         
     elif bodyShape == 2:
         bodyOffset = 0.5
     elif bodyShape == 3:
         bodyOffset = 1
         if gender == 'm':
             topOffset = 0.10000000000000001
             beltOffset = 0.10000000000000001
         elif gender == 'f':
             headOffset = -0.40000000000000002
             topOffset = -0.10000000000000001
             beltOffset = -0.10000000000000001
             pantOffset = -0.10000000000000001
         
     elif bodyShape == 4:
         bodyOffset = 0.5
         if gender == 'm':
             headOffset = -0.20000000000000001
             topOffset = -0.29999999999999999
         elif gender == 'f':
             headOffset = 0.10000000000000001
             beltOffset = 0.10000000000000001
         
     elif bodyShape == 5:
         bodyOffset = 0.5
     elif bodyShape == 6:
         bodyOffset = 0.5
         if gender == 'f':
             headOffset = 0.40000000000000002
             topOffset = 0.40000000000000002
             beltOffset = 0.29999999999999999
         
     elif bodyShape == 7:
         bodyOffset = 0.5
     elif bodyShape == 8:
         bodyOffset = 0.5
         headOffset = -0.20000000000000001
         topOffset = -0.20000000000000001
     elif bodyShape == 9:
         bodyOffset = 0.5
         headOffset = -0.20000000000000001
         topOffset = -0.20000000000000001
     
     m = Mat4(Mat4.identMat())
     topColor = localAvatar.style.getClothesBotColor()
     botColor = localAvatar.style.getClothesTopColor()
     hatColor = localAvatar.style.getHatColor()
     (shirtIdx, shirtTex) = localAvatar.style.getClothesShirt()
     (hatIdx, hatTex) = localAvatar.style.getClothesHat()
     (coatIdx, coatTex) = localAvatar.style.getClothesCoat()
     (beltIdx, beltTex) = localAvatar.style.getClothesBelt()
     (shoeIdx, shoeTex) = localAvatar.style.getClothesShoe()
     (vestIdx, vestTex) = localAvatar.style.getClothesVest()
     (pantIdx, pantTex) = localAvatar.style.getClothesPant()
     dna.setClothesBotColor(topColor[0], topColor[1], topColor[2])
     dna.setClothesTopColor(botColor[0], botColor[1], botColor[2])
     dna.setHatColor(hatColor)
     dna.setClothesShirt(shirtIdx, shirtTex)
     dna.setClothesHat(hatIdx, hatTex)
     dna.setClothesBelt(beltIdx, beltTex)
     dna.setClothesPant(pantIdx, pantTex)
     dna.setClothesShoe(shoeIdx, shoeTex)
     if clothingType == ClothingGlobals.SHIRT:
         dna.setClothesVest(0)
         dna.setClothesCoat(0)
     elif clothingType == ClothingGlobals.VEST:
         dna.setClothesCoat(0)
     elif clothingType == ClothingGlobals.BELT:
         dna.setClothesCoat(0)
         dna.setClothesVest(0)
     else:
         dna.setClothesVest(vestIdx, vestTex)
         dna.setClothesCoat(coatIdx, coatTex)
     dna.setClothesByType(ClothingGlobals.CLOTHING_STRING[clothingType], modelId, texId, self.itemTuple[3])
     self.displayHuman.setDNAString(dna)
     self.displayHuman.generateHuman(gender, self.masterHuman)
     self.displayHuman.stopBlink()
     self.displayHuman.pose('idle', 1)
     lodNode = self.displayHuman.find('**/+LODNode').node()
     lodNode.forceSwitch(lodNode.getHighestSwitch())
     if clothingType == ClothingGlobals.HAT:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_head01').getNetTransform(m)
         headHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = (-headHeight - 0.40000000000000002) + headOffset - bodyHeight * 1.0
         offsetY = 2.0 + bodyOffset
         offsetH = 200
     elif clothingType == ClothingGlobals.SHIRT:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_spine03').getNetTransform(m)
         spine3Height = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
         offsetY = 3.25 + bodyOffset
         offsetH = 200
     elif clothingType == ClothingGlobals.VEST:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_spine03').getNetTransform(m)
         spine3Height = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -spine3Height + topOffset - bodyHeight * 1.3999999999999999
         offsetY = 3.5 + bodyOffset
         offsetH = 200
     elif clothingType == ClothingGlobals.COAT:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_spine02').getNetTransform(m)
         spine2Height = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -spine2Height + topOffset - bodyHeight * 1.3999999999999999
         offsetY = 4.5 + bodyOffset
         offsetH = 200
     elif clothingType == ClothingGlobals.PANT:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_right_knee').getNetTransform(m)
         kneeHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -kneeHeight + pantOffset - 0.5 - bodyHeight * 0.29999999999999999
         offsetY = 4.5 + bodyOffset
         offsetH = 200
     elif clothingType == ClothingGlobals.BELT:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_hips').getNetTransform(m)
         hipHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -hipHeight + beltOffset - bodyHeight * 0.5
         offsetY = 1.7 + bodyOffset
         offsetH = 180
     elif clothingType == ClothingGlobals.SHOE:
         self.displayHuman.getLOD('2000').getChild(0).node().findJoint('def_right_ankle').getNetTransform(m)
         ankleHeight = TransformState.makeMat(m).getPos().getZ()
         offsetZ = -ankleHeight + shoeOffset - 0.14999999999999999 - bodyHeight * -0.10000000000000001
         offsetY = 3.25 + bodyOffset
         offsetH = 200
     else:
         offsetZ = 0
         offsetY = 0
         offsetH = 0
     offsetX = 0
     self.displayHuman.setY(offsetY)
     self.displayHuman.setZ(offsetZ)
     self.displayHuman.setX(offsetX)
     self.displayHuman.setH(offsetH)
     self.displayHuman.reparentTo(self.portraitSceneGraph)
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     if self.showResaleValue:
         value = int(ItemGlobals.getGoldCost(itemId) * ItemGlobals.GOLD_SALE_MULTIPLIER)
     else:
         value = ItemGlobals.getGoldCost(itemId)
     itemCost = int(ItemGlobals.getGoldCost(itemId))
     if self.cell and self.cell.container:
         itemCost = int(itemCost * self.cell.container.getItemPriceMult())
     
     goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale))
     labels.append(goldLabel)
     descriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemFlavorText(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_fg = PiratesGuiGlobals.TextFG0, text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
     dHeight = descriptionLabel.getHeight() + 0.02
     runningVertPosition -= dHeight
     runningSize += dHeight
     labels.append(descriptionLabel)
     if not Freebooter.getPaidStatus(localAvatar.getDoId()):
         if rarity != ItemGlobals.CRUDE:
             unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
             uHeight = unlimitedLabel.getHeight()
             runningVertPosition -= uHeight
             runningSize += uHeight
             labels.append(unlimitedLabel)
         
     
     runningVertPosition -= 0.02
     runningSize += 0.02
     panels = self.helpFrame.attachNewNode('panels')
     topPanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/top_panel').copyTo(topPanel)
     topPanel.setScale(0.080000000000000002)
     topPanel.reparentTo(self.helpFrame)
     middlePanel = panels.attachNewNode('middlePanel')
     detailGui.find('**/middle_panel').copyTo(middlePanel)
     middlePanel.setScale(0.080000000000000002)
     middlePanel.reparentTo(self.helpFrame)
     placement = 0
     i = 0
     heightMax = -0.080000000000000002
     currentHeight = runningVertPosition
     if detailsHeight:
         currentHeight = -detailsHeight
     
     while currentHeight < heightMax:
         middlePanel = panels.attachNewNode('middlePanel%s' % 1)
         detailGui.find('**/middle_panel').copyTo(middlePanel)
         middlePanel.setScale(0.080000000000000002)
         middlePanel.reparentTo(self.helpFrame)
         if currentHeight + 0.20000000000000001 >= heightMax:
             difference = heightMax - currentHeight
             placement += (0.16800000000000001 / 0.20000000000000001) * difference
             currentHeight += difference
         else:
             placement += 0.16800000000000001
             currentHeight += 0.20000000000000001
         middlePanel.setZ(-placement)
         i += 1
     bottomPanel = panels.attachNewNode('bottomPanel')
     detailGui.find('**/bottom_panel').copyTo(bottomPanel)
     bottomPanel.setScale(0.080000000000000002)
     bottomPanel.setZ(-placement)
     bottomPanel.reparentTo(self.helpFrame)
     colorPanel = self.helpFrame.attachNewNode('colorPanel')
     detailGui.find('**/color').copyTo(colorPanel)
     colorPanel.setScale(0.080000000000000002)
     colorPanel.setColor(titleColor)
     colorPanel.reparentTo(self.helpFrame)
     lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel')
     detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel)
     lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007)
     lineBreakTopPanel.setZ(0.0080000000000000002)
     lineBreakTopPanel.reparentTo(self.helpFrame)
     panels.flattenStrong()
     self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin)
     totalHeight = self.helpFrame.getHeight() - 0.10000000000000001
     for label in labels:
         label.reparentTo(self.helpFrame)
     
     if basePosX > 0.0:
         newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001
     else:
         newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001
     if basePosZ > 0.0:
         newPosZ = basePosZ + cellSizeZ * 0.45000000000000001
     else:
         newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
     if detailsPos:
         (newPosX, newPosZ) = detailsPos
     
     self.helpFrame.setPos(newPosX, 0, newPosZ)
コード例 #14
0
    def showDetails(self, cell, detailsPos, detailsHeight, event = None):
        self.notify.debug('Item showDetails')
        if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple):
            self.notify.debug(' early exit')
            return None

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

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

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

        titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale))
        self.bg.setColor(titleColor)
        tHeight = 0.070000000000000007
        titleLabel.setZ(runningVertPosition)
        runningVertPosition -= tHeight
        runningSize += tHeight
        labels.append(titleLabel)
        subtitleLabel = DirectLabel(parent = self, relief = None, text = '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)