Exemple #1
0
    def updateIcons(self):
        shipOV = base.cr.getOwnerView(self.shipId)
        if shipOV:
            shipHullInfo = ShipUpgradeGlobals.HULL_TYPES.get(shipOV.customHull)
            shipRiggingInfo = ShipUpgradeGlobals.RIGGING_TYPES.get(shipOV.customRigging)
            UpgradeIcons = loader.loadModel("models/textureCards/shipUpgradeIcons", okMissing=True)
            skillIcons = loader.loadModel("models/textureCards/skillIcons")
            if shipHullInfo and shipHullInfo["Icon"]:
                if UpgradeIcons:
                    hullImage = UpgradeIcons.find("**/%s" % shipHullInfo["Icon"])
                    self.customHullLabel["geom"] = hullImage

                self.customHullLabel["text"] = shipHullInfo["Name"] + "\n" + PLocalizer.HullLabel
                self.customHullLabel.show()
                self.setShipHp(shipOV.Hp, shipOV.maxHp)
                self.setShipCargo(shipOV.cargo, shipOV.maxCargo)
                if shipHullInfo["BroadsideType"]:
                    broadsideId = shipHullInfo["BroadsideType"]
                    ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                    broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
                    self.broadsideLimit["geom"] = broadsideIcon
                    self.broadsideLimit["geom_scale"] = 0.14999999999999999
                else:
                    broadsideId = InventoryType.CannonRoundShot
                    ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                    broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
                    self.broadsideLimit["geom"] = broadsideIcon
                    self.broadsideLimit["geom_scale"] = 0.14999999999999999

            if shipRiggingInfo and shipRiggingInfo["Icon"]:
                riggingImage = skillIcons.find("**/%s" % shipRiggingInfo["Icon"])
                self.customRiggingLabel["geom"] = riggingImage
                self.customRiggingLabel["text"] = shipRiggingInfo["Name"] + "\n" + PLocalizer.RiggingLabel
                self.customRiggingLabel.show()
Exemple #2
0
 def updateIcons(self):
     shipOV = base.cr.getOwnerView(self.shipId)
     if shipOV:
         shipHullInfo = ShipUpgradeGlobals.HULL_TYPES.get(shipOV.customHull)
         shipRiggingInfo = ShipUpgradeGlobals.RIGGING_TYPES.get(shipOV.customRigging)
         UpgradeIcons = loader.loadModel('models/textureCards/shipUpgradeIcons', okMissing = True)
         skillIcons = loader.loadModel('models/textureCards/skillIcons')
         if shipHullInfo and shipHullInfo['Icon']:
             if UpgradeIcons:
                 hullImage = UpgradeIcons.find('**/%s' % shipHullInfo['Icon'])
                 self.customHullLabel['geom'] = hullImage
             
             self.customHullLabel['text'] = shipHullInfo['Name'] + '\n' + PLocalizer.HullLabel
             self.customHullLabel.show()
             self.setShipHp(shipOV.Hp, shipOV.maxHp)
             self.setShipCargo(shipOV.cargo, shipOV.maxCargo)
             if shipHullInfo['BroadsideType']:
                 broadsideId = shipHullInfo['BroadsideType']
                 ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                 broadsideIcon = skillIcons.find('**/%s' % ammoIconName)
                 self.broadsideLimit['geom'] = broadsideIcon
                 self.broadsideLimit['geom_scale'] = 0.14999999999999999
             else:
                 broadsideId = InventoryType.CannonRoundShot
                 ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                 broadsideIcon = skillIcons.find('**/%s' % ammoIconName)
                 self.broadsideLimit['geom'] = broadsideIcon
                 self.broadsideLimit['geom_scale'] = 0.14999999999999999
         
         if shipRiggingInfo and shipRiggingInfo['Icon']:
             riggingImage = skillIcons.find('**/%s' % shipRiggingInfo['Icon'])
             self.customRiggingLabel['geom'] = riggingImage
             self.customRiggingLabel['text'] = shipRiggingInfo['Name'] + '\n' + PLocalizer.RiggingLabel
             self.customRiggingLabel.show()
 def __init__(self, manager, skillId, itemTuple, imageScaleFactor = 1.0, showMax = 1, update = False):
     self.skillId = skillId
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor, showMax = showMax, update = update)
     self.initialiseoptions(InventoryUIAmmoItem)
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self['image'] = SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillId))
     self.helpFrame = None
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999, -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.10000000000000001)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.iconLabel = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
def getSkillIconName(skillId, frame):
    if skillId == InventoryType.FishingRep:
        return 'pir_t_ico_swd_broadsword_b'
    
    if skillId == InventoryType.CutlassRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.SailingRep:
        return 'sail_full_sail'
    elif skillId == InventoryType.CannonRep:
        return 'pir_t_ico_can_single'
    elif skillId == InventoryType.WandRep:
        return 'pir_t_ico_stf_dark_a'
    elif skillId == InventoryType.MeleeRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.DaggerRep:
        return 'pir_t_ico_knf_small'
    elif skillId == InventoryType.GrenadeRep:
        return 'pir_t_ico_bom_grenade'
    elif skillId == InventoryType.PistolRep:
        return 'pir_t_ico_gun_pistol_a'
    elif skillId == InventoryType.DollRep:
        if frame == 0:
            return 'pir_t_ico_dol_spirit_a'
        else:
            return 'voodoo_attuned'
    else:
        return WeaponGlobals.getSkillIcon(skillId)
def getSkillIconName(skillId, frame):
    if skillId == InventoryType.FishingRep:
        return 'pir_t_ico_swd_broadsword_b'
    
    if skillId == InventoryType.CutlassRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.SailingRep:
        return 'sail_full_sail'
    elif skillId == InventoryType.CannonRep:
        return 'pir_t_ico_can_single'
    elif skillId == InventoryType.WandRep:
        return 'pir_t_ico_stf_dark_a'
    elif skillId == InventoryType.MeleeRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.DaggerRep:
        return 'pir_t_ico_knf_small'
    elif skillId == InventoryType.GrenadeRep:
        return 'pir_t_ico_bom_grenade'
    elif skillId == InventoryType.PistolRep:
        return 'pir_t_ico_gun_pistol_a'
    elif skillId == InventoryType.DollRep:
        if frame == 0:
            return 'pir_t_ico_dol_spirit_a'
        else:
            return 'voodoo_attuned'
    else:
        return WeaponGlobals.getSkillIcon(skillId)
 def __init__(self, uid):
     SimpleEconomyItem.__init__(self, uid)
     skillId = WeaponGlobals.getSkillIdForAmmoSkillId(uid)
     if skillId:
         asset = WeaponGlobals.getSkillIcon(skillId)
         if asset:
             self.icon = self.Icons.find('**/%s' % asset)
             self.iconScale = 1.1000000000000001
             self.iconHpr = (0, 0, 45)
 def __init__(self, uid):
     SimpleEconomyItem.__init__(self, uid)
     skillId = WeaponGlobals.getSkillIdForAmmoSkillId(uid)
     if skillId:
         asset = WeaponGlobals.getSkillIcon(skillId)
         if asset:
             self.icon = self.Icons.find('**/%s' % asset)
             self.iconScale = 1.1000000000000001
             self.iconHpr = (0, 0, 45)
Exemple #8
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent=self, relief=None, state=DGG.DISABLED, pos=(0.035,
                                                                                   0,
                                                                                   0.025))
     self.quantityLabel = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, text=str(self.quantity), text_fg=PiratesGuiGlobals.TextFG2, text_scale=PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align=TextNode.ARight, text_wordwrap=11, pos=(0.1225,
                                                                                                                                                                                                                                                                                0,
                                                                                                                                                                                                                                                                                0.015))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     else:
         if len(self.name) >= 35:
             textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
         else:
             textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
         self.nameTag = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, text=self.name, text_fg=PiratesGuiGlobals.TextFG2, text_scale=textScale, text_align=TextNode.ALeft, pos=(0.13,
                                                                                                                                                                                           0,
                                                                                                                                                                                           0.015))
         self.costText = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, image=InventoryListItem.coinImage, image_scale=0.12, image_pos=Vec3(-0.005, 0, 0.0125), text=str(self.price), text_fg=PiratesGuiGlobals.TextFG2, text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ARight, text_wordwrap=11, text_pos=(-0.03, 0, 0), pos=(self.width - 0.035, 0, 0.015), text_font=PiratesGlobals.getInterfaceFont())
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         if InventoryType.begin_WeaponCannonAmmo <= itemId and itemId <= InventoryType.end_WeaponCannonAmmo or InventoryType.begin_WeaponPistolAmmo <= itemId and itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.06
                     self.picture['geom_pos'] = (0, 0, 0)
         if InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.1
             self.picture['geom_pos'] = (0, 0, 0)
     self.flattenStrong()
     return
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.035000000000000003, 0, 0.025000000000000001))
     self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ARight, text_wordwrap = 11, pos = (0.1225, 0, 0.014999999999999999))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     elif len(self.name) >= 35:
         textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
     else:
         textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_fg = PiratesGuiGlobals.TextFG2, text_scale = textScale, text_align = TextNode.ALeft, pos = (0.13, 0, 0.014999999999999999))
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.0050000000000000001, 0, 0.012500000000000001), text = str(self.price), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.014999999999999999), text_font = PiratesGlobals.getInterfaceFont())
     itemClass = EconomyGlobals.getItemCategory(itemId)
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.059999999999999998
                     self.picture['geom_pos'] = (0, 0, 0)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     self.flattenStrong()
    def updateSkillId(self, skillId):
        self.skillId = skillId
        if self.skillButton:
            if self.quantityLabel:
                self.quantityLabel.detachNode()

            self.skillButton.destroy()

        if self.showQuantity and not (self.quantity):
            geomColor = Vec4(0.5, 0.5, 0.5, 1.0)
        else:
            geomColor = Vec4(1.0, 1.0, 1.0, 1.0)
        if self.showIcon:
            asset = WeaponGlobals.getSkillIcon(skillId)
            if hasattr(self, '_skillIconName'):
                asset = self._skillIconName

            geom = SkillButton.SkillIcons.find('**/%s' % asset)
            if geom.isEmpty():
                geom = SkillButton.SkillIcons.find('**/base')

            repId = WeaponGlobals.getSkillReputationCategoryId(self.skillId)
            geom_scale = getGeomScale(repId, skillId)
            image_color = (1, 1, 1, 1)
        else:
            geom = (None,)
            geom_scale = 0.12
            image_color = (0.5, 0.5, 0.5, 0.5)
        specialIconId = 0
        if self.isBreakAttackSkill:
            specialIconId = 1
        elif self.isDefenseSkill:
            specialIconId = 2
        elif skillId == ItemGlobals.getSpecialAttack(localAvatar.currentWeaponId):
            specialIconId = 3

        if specialIconId:
            something = SkillButton.SpecialIcons[specialIconId][0]
            if self.skillRing:
                self.skillRing.setupFace(something)

            self['image'] = None
        elif self.skillRing:
            self.skillRing.setupFace()

        if self.showRing:
            image = None
        else:
            image = SkillButton.Image
        self.skillButton = DirectButton(parent = self, relief = None, pos = (0, 0, 0), text = ('', '', self.name), text_align = TextNode.ACenter, text_shadow = Vec4(0, 0, 0, 1), text_scale = 0.040000000000000001, text_fg = Vec4(1, 1, 1, 1), text_pos = (0.0, 0.089999999999999997), image = image, image_scale = 0.14999999999999999, image_color = image_color, geom = geom, geom_scale = geom_scale, geom_color = geomColor, command = self.callback, sortOrder = 50, extraArgs = [
            skillId])
        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel.reparentTo(self.skillButton)
 def getGeomParams(itemId):
     geomParams = { }
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         if itemType == ItemType.POTION:
             geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
         else:
             itemType = ItemGlobals.getType(itemId)
             if ItemGlobals.getIcon(itemId):
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
             
         geomParams['geom_scale'] = 0.11
         geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
     else:
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.fishingIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.WEAPON and itemClass == ItemType.POUCH or itemClass == ItemType.AMMO:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     geomParams['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     geomParams['geom_scale'] = 0.14999999999999999
                     geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             geomParams['geom'] = InventoryListItem.topGui.find('**/main_gui_ship_bottle')
             geomParams['geom_scale'] = 0.10000000000000001
             geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     return geomParams
Exemple #12
0
 def updateSkillId(self, skillId):
     self.skillId = skillId
     if self.skillButton:
         if self.quantityLabel:
             self.quantityLabel.detachNode()
         
         self.skillButton.destroy()
     
     if self.showQuantity and not (self.quantity):
         geomColor = Vec4(0.5, 0.5, 0.5, 1.0)
     else:
         geomColor = Vec4(1.0, 1.0, 1.0, 1.0)
     if self.showIcon:
         asset = WeaponGlobals.getSkillIcon(skillId)
         if hasattr(self, '_skillIconName'):
             asset = self._skillIconName
         
         geom = SkillButton.SkillIcons.find('**/%s' % asset)
         if geom.isEmpty():
             geom = SkillButton.SkillIcons.find('**/base')
         
         repId = WeaponGlobals.getSkillReputationCategoryId(self.skillId)
         geom_scale = getGeomScale(repId, skillId)
         image_color = (1, 1, 1, 1)
     else:
         geom = (None,)
         geom_scale = 0.12
         image_color = (0.5, 0.5, 0.5, 0.5)
     specialIconId = 0
     if self.isBreakAttackSkill:
         specialIconId = 1
     elif self.isDefenseSkill:
         specialIconId = 2
     elif skillId == ItemGlobals.getSpecialAttack(localAvatar.currentWeaponId):
         specialIconId = 3
     
     if specialIconId:
         something = SkillButton.SpecialIcons[specialIconId][0]
         if self.skillRing:
             self.skillRing.setupFace(something)
         
         self['image'] = None
     elif self.skillRing:
         self.skillRing.setupFace()
     
     if self.showRing:
         image = None
     else:
         image = SkillButton.Image
     self.skillButton = DirectButton(parent = self, relief = None, pos = (0, 0, 0), text = ('', '', self.name), text_align = TextNode.ACenter, text_shadow = Vec4(0, 0, 0, 1), text_scale = 0.040000000000000001, text_fg = Vec4(1, 1, 1, 1), text_pos = (0.0, 0.089999999999999997), image = image, image_scale = 0.14999999999999999, image_color = image_color, geom = geom, geom_scale = geom_scale, geom_color = geomColor, command = self.callback, sortOrder = 50, extraArgs = [
         skillId])
     self.skillButton.bind(DGG.ENTER, self.showDetails)
     self.skillButton.bind(DGG.EXIT, self.hideDetails)
     if self.quantityLabel and not self.quantityLabel.isEmpty():
         self.quantityLabel.reparentTo(self.skillButton)
Exemple #13
0
 def isSkillValid(self, skillId):
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     ammoName = PLocalizer.InventoryTypeNames.get(ammoId)
     ammoDescription = PLocalizer.WeaponDescriptions.get(ammoId)
     ammoIconName = WeaponGlobals.getSkillIcon(skillId)
     ammoIcon = self.SkillIcons.find('**/%s' % ammoIconName)
     skillRepId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     stackLimit = localAvatar.getInventory().getStackLimit(ammoId)
     if ammoName and ammoDescription and ammoIcon and stackLimit:
         return 1
     else:
         return 0
 def isSkillValid(self, skillId):
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     ammoName = PLocalizer.InventoryTypeNames.get(ammoId)
     ammoDescription = PLocalizer.WeaponDescriptions.get(ammoId)
     ammoIconName = WeaponGlobals.getSkillIcon(skillId)
     ammoIcon = self.SkillIcons.find("**/%s" % ammoIconName)
     skillRepId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     stackLimit = localAvatar.getInventory().getStackLimit(ammoId)
     if ammoName and ammoDescription and ammoIcon and stackLimit:
         return 1
     else:
         return 0
 def isSkillValid(self, skillId):
     return WeaponGlobals.getSkillAmmoInventoryId(skillId) in InventoryGlobals.AmmoInGUI
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     ammoName = PLocalizer.InventoryTypeNames.get(ammoId)
     ammoDescription = PLocalizer.WeaponDescriptions.get(ammoId)
     ammoIconName = WeaponGlobals.getSkillIcon(skillId)
     ammoIcon = SkillIcons.find('**/%s' % ammoIconName)
     skillRepId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     if ammoName and ammoDescription and ammoIcon and skillRepId:
         return 1
     else:
         return 0
 def __init__(self,
              manager,
              skillId,
              itemTuple,
              imageScaleFactor=1.0,
              showMax=1,
              update=False):
     self.skillId = skillId
     InventoryUIStackItem.InventoryUIStackItem.__init__(
         self,
         manager,
         itemTuple,
         imageScaleFactor=imageScaleFactor,
         showMax=showMax,
         update=update)
     self.initialiseoptions(InventoryUIAmmoItem)
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self['image'] = SkillIcons.find('**/%s' %
                                     WeaponGlobals.getSkillIcon(skillId))
     self.helpFrame = None
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.3, 0.3, -0.09, 0.09)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.1)
     self.lens.setAspectRatio(0.6 / 0.18)
     self.realItem = None
     self.iconLabel = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.3)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.3)
     self.glow.setColor(1, 1, 1, 0.8)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
     self['image_scale'] = 0.1 * imageScaleFactor
     return
Exemple #17
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)
Exemple #18
0
 def createGui(self):
     itemId = self.data[0]
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.01, 0, 0.01))
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.050000000000000003, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     itemTypeFormatted = ''
     self.itemTypeName = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = itemTypeFormatted, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.050000000000000003, 0, 0.065000000000000002))
     self.miscText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = '', text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.050000000000000003, 0, 0.025000000000000001))
     if self.minLvl > 0:
         repId = WeaponGlobals.getRepId(itemId)
         if repId:
             self.checkLevel(repId, self.minLvl)
         
     
     trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
     if trainingReq:
         self.checkTrainingReq(trainingReq)
     
     if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
         skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
         self.checkSkillReq(skillId)
     
     if self.buy:
         self.checkPlayerInventory(itemId)
     
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = SongListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.01, 0, 0.01), text = str(self.price), text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     if self.quantity and self.quantity > 1:
         self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), frameColor = (0, 0, 0, 1), frameSize = (-0.01, 0.02, -0.01, 0.025000000000000001), text_scale = 0.0275, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.02, 0, 0.025000000000000001), text_font = PiratesGlobals.getPirateBoldOutlineFont())
     
     itemClass = EconomyGlobals.getItemCategory(itemId)
     if itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = SongItemGui.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.11
             self.picture['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = SongItemGui.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.11
             self.picture['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = SongListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.14999999999999999
                     self.picture['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = SongListItem.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     self.flattenStrong()
Exemple #19
0
    def __init__(self, shipPage, shipId, **kwargs):
        self.shipPage = shipPage
        self.emptyBottle = True
        self.setShipId(shipId)
        self.timer = None
        self.lBroadsideLimit = 0
        self.rBroadsideLimit = 0
        kwargs.setdefault("relief", None)
        kwargs.setdefault("frameSize", (0, self.Width, 0, self.Height))
        DirectFrame.__init__(self, **None)
        self.initialiseoptions(ShipPanel)
        gui = loader.loadModel("models/gui/toplevel_gui")
        inventoryGui = loader.loadModel("models/gui/gui_icons_inventory")
        chestIcon = inventoryGui.find("**/pir_t_ico_trs_chest_01*")
        cannonIcon = gui.find("**/topgui_icon_ship_cannon_single")
        skillIcons = loader.loadModel("models/textureCards/skillIcons")
        broadsideId = InventoryType.CannonRoundShot
        ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
        broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
        crewIcon = (gui.find("**/pir_t_gui_gen_friends_pirates"),)
        self.bottleFrame = ShipFrameBottle(
            parent=self,
            shipId=shipId,
            relief=None,
            state=DGG.DISABLED,
            pos=(0.074999999999999997, 0, 0.75),
            scale=0.83499999999999996,
        )
        gui = loader.loadModel("models/gui/gui_ship_window")
        bottleImage = gui.find("**/ship_bottle")
        self.shipBottle = DirectLabel(
            parent=self.bottleFrame,
            relief=None,
            state=DGG.DISABLED,
            geom=bottleImage,
            geom_scale=0.29999999999999999,
            geom_pos=(0, 0, 0),
            pos=(0.5, 0, -0.0),
        )
        self.nameLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottle, 2),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_scale=PiratesGuiGlobals.TextScaleTitleSmall,
            text_align=TextNode.ACenter,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getPirateFont(),
            pos=(0.55000000000000004, 0, 1.22),
        )
        self.classLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottleDesc, 1),
            text_scale=PiratesGuiGlobals.TextScaleMed,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.55000000000000004, 0, 1.1799999999999999),
        )
        self.timer = PiratesTimer.PiratesTimer(
            showMinutes=True, mode=None, titleText="", titleFg="", infoText="", cancelText="", cancelCallback=None
        )
        self.timer.setFontColor(PiratesGuiGlobals.TextFG2)
        self.timer.reparentTo(self)
        self.timer.setPos(0.45000000000000001, 0, 0.93999999999999995)
        self.timer.setScale(0.59999999999999998)
        self.timer.stash()
        self.hpMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.10000000000000001, 0.69999999999999996, 0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text="",
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.45000000000000001),
            scale=1.2,
        )
        hpLabel = DirectLabel(
            parent=self.hpMeter,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.HP,
            text_scale=0.029999999999999999,
            text_align=TextNode.ALeft,
            text_pos=(0.014999999999999999, 0.029999999999999999),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.speedMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.69999999999999996, 0.69999999999999996, 0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text="",
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.34999999999999998),
            scale=1.2,
        )
        speedLabel = DirectLabel(
            parent=self.speedMeter,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Sails,
            text_scale=0.029999999999999999,
            text_align=TextNode.ALeft,
            text_pos=(0.014999999999999999, 0.029999999999999999),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.customHullLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.34999999999999998, 0, 0.68000000000000005),
        )
        self.customHullLabel.hide()
        self.customRiggingLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.75, 0, 0.68000000000000005),
        )
        self.customRiggingLabel.hide()
        textPos = (0.0, -0.16)
        self.plunderLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.10000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.20000000000000001, 0, 0.20000000000000001),
        )
        plunderLabel = DirectLabel(
            parent=self.plunderLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Cargo,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0, 0.040000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.cannonLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=cannonIcon,
            geom_scale=0.45000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.37, 0, 0.20000000000000001),
        )
        cannonLabel = DirectLabel(
            parent=self.cannonLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Cannon,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0, 0.040000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.cannonLabel = cannonLabel
        self.broadsideLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=broadsideIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.81000000000000005, 0, 0.20000000000000001),
        )
        broadsideLabel = DirectLabel(
            parent=self.broadsideLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Broadsides,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.0, 0.040000000000000001),
        )
        self.broadsideLabel = broadsideLabel
        self.crewLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=crewIcon,
            geom_scale=0.40000000000000002,
            geom_pos=(0, 0, 0.10000000000000001),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.56000000000000005, 0, 0.040000000000000001),
        )
        crewLabel = DirectLabel(
            parent=self.crewLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Crew,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0.0, 0.20000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.crewLabel = crewLabel
        shipOV = base.cr.getOwnerView(self.shipId)
        if shipOV:
            self.setShipName(shipOV.name)
            self.setShipClass(shipOV.shipClass)
            self.setShipHp(shipOV.Hp, shipOV.maxHp)
            self.setShipSp(shipOV.Sp, shipOV.maxSp)
            self.setShipCrew(shipOV.crew, shipOV.maxCrew)
            self.setShipCargo([], shipOV.maxCargo)
            if hasattr(shipOV, "cannonConfig"):
                self.setShipMaxCannons(shipOV.cannonConfig)
                self.setShipMaxBroadside(shipOV.lBroadsideConfig, shipOV.rBroadsideConfig)

            self.updateIcons()

        if self.emptyBottle:
            self.hpMeter.hide()
            self.speedMeter.hide()
            self.plunderLimit.hide()
            self.cannonLimit.hide()
            self.broadsideLimit.hide()
            self.crewLimit.hide()

        self.accept("setName-%s" % self.shipId, self.setShipName)
        self.accept("setShipClass-%s" % self.shipId, self.setShipClass)
        self.accept("setShipHp-%s" % self.shipId, self.setShipHp)
        self.accept("setShipSp-%s" % self.shipId, self.setShipSp)
        self.accept("setShipCargo-%s" % self.shipId, self.setShipCargo)
        self.accept("setShipCrew-%s" % self.shipId, self.setShipCrew)
        self.accept("setShipTimer-%s" % self.shipId, self.setShipTimer)
        self.accept("setHullCannonConfig-%s" % self.shipId, self.setShipMaxCannons)
        self.accept("setHullLeftBroadsideConfig-%s" % self.shipId, self.setShipMaxLeftBroadside)
        self.accept("setHullRightBroadsideConfig-%s" % self.shipId, self.setShipMaxRightBroadside)
        self.accept("ShipChanged-%s" % self.shipId, self.handleShipChanged)
        if base.config.GetBool("want-deploy-button", 0):
            pass
        1
 def _createIface(self):
     self.descText = DirectLabel(parent = self, relief = None, text = self.item.get('Text'), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.02, 0, self.height / 2), text_font = PiratesGlobals.getInterfaceOutlineFont())
     self.valueText = DirectLabel(parent = self, relief = None, text = str(self.item.get('Value1')), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (self.width * 0.65000000000000002, 0, self.height / 2), text_font = PiratesGlobals.getInterfaceOutlineFont())
     if self.item.get('Type') == 'Title':
         self.descText['text_scale'] = 0.055
         self.descText['text_fg'] = PiratesGuiGlobals.TextFG1
         self.descText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.valueText['text_scale'] = 0.044999999999999998
         self.valueText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         if self.item.has_key('Value2'):
             self.valueText2 = DirectLabel(parent = self, relief = None, text = str(self.item.get('Value2')), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (self.width * 0.80000000000000004, 0, self.height / 2), text_font = PiratesGlobals.getInterfaceOutlineFont())
         
         if self.valueText2:
             self.valueText2['text_scale'] = 0.044999999999999998
             self.valueText2['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         
     elif self.item.get('Type') == 'Entry':
         self.descText['text_pos'] = (self.width * 0.059999999999999998, 0, 0)
         if self.item.has_key('Value2'):
             self.valueText2 = DirectLabel(parent = self, relief = None, text = str(self.item.get('Value2')), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (self.width * 0.80000000000000004, 0, self.height / 2), text_font = PiratesGlobals.getInterfaceOutlineFont())
         
     elif self.item.get('Type') == 'Space':
         self.descText['text_scale'] = 0.02
         self.descText['text'] = ' '
         self.valueText['text_scale'] = 0.02
         self.valueText['text'] = ' '
     elif self.item.get('Type') == 'Button':
         self.descText['text_pos'] = (self.width * 0.059999999999999998, 0, 0)
         self.valueText['text'] = ' '
         self.button = DirectButton(parent = self, relief = DGG.RIDGE, text = self.item.get('Text'), text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, frameColor = PiratesGuiGlobals.ButtonColor1, command = self.item.get('Value2'), pos = (self.width * 0.65000000000000002, 0, self.height / 2), borderWidth = (0.01, 0.01), pad = (0.0050000000000000001, 0.0050000000000000001), textMayChange = 1)
         if self.item.get('State') == 'off':
             self.button['state'] = DGG.DISABLED
             self.button['text_fg'] = PiratesGuiGlobals.TextFG3
         elif self.item.get('State') == 'oneShot':
             self.button.bind(DGG.B1RELEASE, self.disableButton)
         
     elif self.item.get('Type') == 'Cargo':
         itemId = self.item.get('Value1')
         iconId = EconomyGlobals.getCargoCategory(itemId)
         if not iconId:
             self.notify.error('Invalid Item in Cargo! item: %s' % (self.item,))
         
         icon = self.icons.get(iconId)
         self.descText['geom'] = self.getCargoIcon(icon[0])
         self.descText['geom_scale'] = 0.089999999999999997 * self.height * 10
         self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
         self.descText['text_pos'] = (0.23999999999999999, 0, 0)
         self.descText['text'] = icon[1]
         self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
         self.descText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.descText['text_scale'] = 0.050000000000000003 * self.height * 10
         self.descText.setTransparency(1)
         self.valueText['text'] = PLocalizer.UnknownGoldValue
         self.valueText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.valueText['text_scale'] = 0.050000000000000003 * self.height * 10
         icon = self.icons.get(ItemId.CARGO_CRATE)
         self.descText2 = DirectLabel(parent = self, relief = None, text = '?', text_align = TextNode.ACenter, text_scale = 0.050000000000000003 * self.height * 10, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.080000000000000002, 0, self.height / 2), geom = self.getCargoIcon(icon[0]), geom_scale = 0.089999999999999997 * self.height * 10, geom_pos = (0.10000000000000001, 0, 0.01), text_pos = (0.10000000000000001, 0, 0), geom_color = Vec4(0, 0, 0, 1), text_font = PiratesGlobals.getInterfaceOutlineFont())
     elif self.item.get('Type') == 'Gold':
         amount = self.item.get('Value2')
         itemName = PLocalizer.LootGold % amount
         self.descText['geom'] = self.getGoldIcon()
         self.descText['geom_scale'] = 0.14999999999999999 * self.height * 10
         self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
         self.descText['text_pos'] = (0.23999999999999999, 0, 0)
         self.descText['text'] = itemName
         self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
         self.descText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.descText['text_scale'] = 0.050000000000000003 * self.height * 10
         self.descText.setTransparency(1)
         self.valueText['text'] = ' '
     elif self.item.get('Type') == 'Weapon':
         itemId = self.item.get('Value1')
         itemName = PLocalizer.InventoryTypeNames.get(itemId)
         iconName = EconomyGlobals.getItemIcons(itemId)
         self.descText['geom'] = self.getWeaponIcon(iconName)
         self.descText['geom_scale'] = 0.089999999999999997 * self.height * 10
         self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
         self.descText['text_pos'] = (0.23999999999999999, 0, 0)
         self.descText['text'] = itemName
         self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
         self.descText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.descText['text_scale'] = 0.050000000000000003 * self.height * 10
         self.descText.setTransparency(1)
         self.valueText['text'] = ' '
     elif self.item.get('Type') == 'Ammo':
         itemId = self.item.get('Value1')
         amount = self.item.get('Value2')
         itemName = '%s %s' % (amount, PLocalizer.InventoryTypeNames.get(itemId))
         iconName = WeaponGlobals.getSkillIcon(itemId)
         self.descText['geom'] = self.getAmmoIcon(iconName)
         self.descText['geom_scale'] = 0.089999999999999997 * self.height * 10
         self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
         self.descText['text_pos'] = (0.23999999999999999, 0, 0)
         self.descText['text'] = itemName
         self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
         self.descText['text_font'] = PiratesGlobals.getInterfaceOutlineFont()
         self.descText['text_scale'] = 0.050000000000000003 * self.height * 10
         self.descText.setTransparency(1)
         self.valueText['text'] = ' '
Exemple #21
0
    def createGui(self):
        itemId = self.data[0]
        self.picture = DirectFrame(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   pos=(0.01, 0, 0.01))
        self.nameTag = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=self.name,
            text_scale=PiratesGuiGlobals.TextScaleSmall *
            PLocalizer.getHeadingScale(2),
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(0.050000000000000003, 0, 0.105),
            text_font=PiratesGlobals.getInterfaceFont())
        itemTypeFormatted = ''
        self.itemTypeName = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=itemTypeFormatted,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.050000000000000003, 0, 0.065000000000000002))
        self.miscText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text='',
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            pos=(0.050000000000000003, 0, 0.025000000000000001))
        if self.minLvl > 0:
            repId = WeaponGlobals.getRepId(itemId)
            if repId:
                self.checkLevel(repId, self.minLvl)

        trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
        if trainingReq:
            self.checkTrainingReq(trainingReq)

        if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
            skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
            self.checkSkillReq(skillId)

        if self.buy:
            self.checkPlayerInventory(itemId)

        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            image=SongListItem.coinImage,
            image_scale=0.12,
            image_pos=Vec3(-0.01, 0, 0.01),
            text=str(self.price),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            text_pos=(-0.029999999999999999, 0, 0),
            pos=(self.width - 0.035000000000000003, 0, 0.105),
            text_font=PiratesGlobals.getInterfaceFont())
        if self.quantity and self.quantity > 1:
            self.quantityLabel = DirectLabel(
                parent=self,
                relief=None,
                state=DGG.DISABLED,
                text=str(self.quantity),
                frameColor=(0, 0, 0, 1),
                frameSize=(-0.01, 0.02, -0.01, 0.025000000000000001),
                text_scale=0.0275,
                text_align=TextNode.ACenter,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_wordwrap=11,
                pos=(0.02, 0, 0.025000000000000001),
                text_font=PiratesGlobals.getPirateBoldOutlineFont())

        itemClass = EconomyGlobals.getItemCategory(itemId)
        if itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = SongItemGui.weaponIcons.find('**/%s*' %
                                                                    asset)
                self.picture['geom_scale'] = 0.11
                self.picture['geom_pos'] = (0.080000000000000002, 0,
                                            0.068000000000000005)

        elif itemClass == ItemType.CONSUMABLE:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = SongItemGui.skillIcons.find('**/%s*' %
                                                                   asset)
                self.picture['geom_scale'] = 0.11
                self.picture['geom_pos'] = (0.080000000000000002, 0,
                                            0.068000000000000005)

        if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
            if (InventoryType.begin_WeaponPistolAmmo <= itemId
                    or itemId <= InventoryType.end_WeaponGrenadeAmmo
                    or InventoryType.begin_WeaponDaggerAmmo <= itemId
                ) and itemId <= InventoryType.end_WeaponDaggerAmmo:
                skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
                if skillId:
                    asset = WeaponGlobals.getSkillIcon(skillId)
                    if asset:
                        self.picture['geom'] = SongListItem.skillIcons.find(
                            '**/%s' % asset)
                        self.picture['geom_scale'] = 0.14999999999999999
                        self.picture['geom_pos'] = (0.069000000000000006, 0,
                                                    0.069000000000000006)

            elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
                self.picture['geom'] = SongListItem.topGui.find(
                    '**/main_gui_ship_bottle')
                self.picture['geom_scale'] = 0.10000000000000001
                self.picture['geom_pos'] = (0.069000000000000006, 0,
                                            0.069000000000000006)

        self.flattenStrong()
 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 or self.manager.locked or cell.isEmpty(
        ) or self.isEmpty() or not self.itemTuple:
            self.notify.debug(' early exit')
            return
        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*')
        SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        border = 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.TextFG24
        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=PLocalizer.InventoryItemClassNames.get(
                EconomyGlobals.getItemType(self.getId()), ''),
            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)
        self.iconLabel = DirectLabel(
            parent=self.portraitSceneGraph,
            relief=None,
            image=SkillIcons.find(
                '**/%s' % WeaponGlobals.getSkillIcon(self.getSkillId())),
            pos=(0.0, 2.5, 0.0))
        iHeight = 0.18
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.06)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        description = PLocalizer.WeaponDescriptions.get(self.getId())
        if not description:
            description = PLocalizer.WeaponDescriptions.get(self.getSkillId())
        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)
        runningVertPosition -= 0.02
        runningSize += 0.02
        panels = self.helpFrame.attachNewNode('panels')
        topPanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/top_panel').copyTo(topPanel)
        topPanel.setScale(0.08)
        topPanel.reparentTo(self.helpFrame)
        middlePanel = panels.attachNewNode('middlePanel')
        detailGui.find('**/middle_panel').copyTo(middlePanel)
        middlePanel.setScale(0.08)
        middlePanel.reparentTo(self.helpFrame)
        placement = 0
        i = 0
        heightMax = -0.08
        currentHeight = runningVertPosition
        if detailsHeight:
            currentHeight = -detailsHeight
        while currentHeight < heightMax:
            middlePanel = panels.attachNewNode('middlePanel%s' % 1)
            detailGui.find('**/middle_panel').copyTo(middlePanel)
            middlePanel.setScale(0.08)
            middlePanel.reparentTo(self.helpFrame)
            if currentHeight + 0.2 >= heightMax:
                difference = heightMax - currentHeight
                placement += 0.168 / 0.2 * difference
                currentHeight += difference
            else:
                placement += 0.168
                currentHeight += 0.2
            middlePanel.setZ(-placement)
            i += 1

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

        if basePosX > 0.0:
            newPosX = basePosX - (halfWidth + cellSizeX * 0.45)
        else:
            newPosX = basePosX + (halfWidth + cellSizeX * 0.45)
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
    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)
Exemple #25
0
 def __init__(self, shipPage, shipId, **kwargs):
     self.shipPage = shipPage
     self.emptyBottle = True
     self.setShipId(shipId)
     self.timer = None
     self.lBroadsideLimit = 0
     self.rBroadsideLimit = 0
     kwargs.setdefault('relief', None)
     kwargs.setdefault('frameSize', (0, self.Width, 0, self.Height))
     DirectFrame.__init__(self, **kwargs)
     self.initialiseoptions(ShipPanel)
     gui = loader.loadModel('models/gui/toplevel_gui')
     inventoryGui = loader.loadModel('models/gui/gui_icons_inventory')
     chestIcon = inventoryGui.find('**/pir_t_ico_trs_chest_01*')
     cannonIcon = gui.find('**/topgui_icon_ship_cannon_single')
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     broadsideId = InventoryType.CannonRoundShot
     ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
     broadsideIcon = skillIcons.find('**/%s' % ammoIconName)
     crewIcon = (gui.find('**/pir_t_gui_gen_friends_pirates'), )
     self.bottleFrame = ShipFrameBottle(parent=self,
                                        shipId=shipId,
                                        relief=None,
                                        state=DGG.DISABLED,
                                        pos=(0.075, 0, 0.75),
                                        scale=0.835)
     gui = loader.loadModel('models/gui/gui_ship_window')
     bottleImage = gui.find('**/ship_bottle')
     self.shipBottle = DirectLabel(parent=self.bottleFrame,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   geom=bottleImage,
                                   geom_scale=0.3,
                                   geom_pos=(0, 0, 0),
                                   pos=(0.5, 0, -0.0))
     self.nameLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottle, 2),
         text_fg=PiratesGuiGlobals.TextFG1,
         text_scale=PiratesGuiGlobals.TextScaleTitleSmall,
         text_align=TextNode.ACenter,
         text_shadow=(0, 0, 0, 1),
         text_wordwrap=30,
         textMayChange=1,
         text_font=PiratesGlobals.getPirateFont(),
         pos=(0.55, 0, 1.22))
     self.classLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottleDesc, 1),
         text_scale=PiratesGuiGlobals.TextScaleMed,
         text_align=TextNode.ACenter,
         text_fg=PiratesGuiGlobals.TextFG2,
         text_shadow=(0, 0, 0, 1),
         text_wordwrap=30,
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceFont(),
         pos=(0.55, 0, 1.18))
     self.timer = PiratesTimer.PiratesTimer(showMinutes=True,
                                            mode=None,
                                            titleText='',
                                            titleFg='',
                                            infoText='',
                                            cancelText='',
                                            cancelCallback=None)
     self.timer.setFontColor(PiratesGuiGlobals.TextFG2)
     self.timer.reparentTo(self)
     self.timer.setPos(0.45, 0, 0.94)
     self.timer.setScale(0.6)
     self.timer.stash()
     self.hpMeter = DirectWaitBar(parent=self,
                                  relief=DGG.RAISED,
                                  state=DGG.DISABLED,
                                  range=1,
                                  value=0,
                                  frameColor=(0.0, 0.0, 0.0, 0.0),
                                  barColor=(0.1, 0.7, 0.1, 1),
                                  frameSize=(0, 0.31, 0, 0.0186),
                                  text='',
                                  text_align=TextNode.ARight,
                                  text_scale=0.03,
                                  text_fg=(1, 1, 1, 1),
                                  text_shadow=(0, 0, 0, 1),
                                  text_pos=(0.3, 0.03),
                                  pos=(0.55, 0.0, 0.45),
                                  scale=1.2)
     hpLabel = DirectLabel(parent=self.hpMeter,
                           relief=None,
                           state=DGG.DISABLED,
                           text=PLocalizer.HP,
                           text_scale=0.03,
                           text_align=TextNode.ALeft,
                           text_pos=(0.015, 0.03),
                           text_fg=(1, 1, 1, 1),
                           text_shadow=(0, 0, 0, 1))
     self.speedMeter = DirectWaitBar(parent=self,
                                     relief=DGG.RAISED,
                                     state=DGG.DISABLED,
                                     range=1,
                                     value=0,
                                     frameColor=(0.0, 0.0, 0.0, 0.0),
                                     barColor=(0.7, 0.7, 0.1, 1),
                                     frameSize=(0, 0.31, 0, 0.0186),
                                     text='',
                                     text_align=TextNode.ARight,
                                     text_scale=0.03,
                                     text_fg=(1, 1, 1, 1),
                                     text_shadow=(0, 0, 0, 1),
                                     text_pos=(0.3, 0.03),
                                     pos=(0.55, 0.0, 0.35),
                                     scale=1.2)
     speedLabel = DirectLabel(parent=self.speedMeter,
                              relief=None,
                              state=DGG.DISABLED,
                              text=PLocalizer.Sails,
                              text_scale=0.03,
                              text_align=TextNode.ALeft,
                              text_pos=(0.015, 0.03),
                              text_fg=(1, 1, 1, 1),
                              text_shadow=(0, 0, 0, 1))
     self.customHullLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=chestIcon,
         geom_scale=0.15,
         geom_pos=(0, 0, 0),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_pos=(0, -0.07),
         text_fg=PiratesGuiGlobals.TextFG1,
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.35, 0, 0.68))
     self.customHullLabel.hide()
     self.customRiggingLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=chestIcon,
         geom_scale=0.15,
         geom_pos=(0, 0, 0),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_pos=(0, -0.07),
         text_fg=PiratesGuiGlobals.TextFG1,
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.75, 0, 0.68))
     self.customRiggingLabel.hide()
     textPos = (0.0, -0.16)
     self.plunderLimit = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=chestIcon,
         geom_scale=0.1,
         geom_pos=(0, 0, -0.05),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_pos=textPos,
         text_fg=(1, 1, 1, 1),
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.2, 0, 0.2))
     plunderLabel = DirectLabel(parent=self.plunderLimit,
                                relief=None,
                                state=DGG.DISABLED,
                                text=PLocalizer.Cargo,
                                text_scale=0.036,
                                text_align=TextNode.ACenter,
                                text_pos=(0, 0.04),
                                text_fg=(1, 1, 1, 1),
                                text_shadow=(0, 0, 0, 1))
     self.cannonLimit = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=cannonIcon,
         geom_scale=0.45,
         geom_pos=(0, 0, -0.05),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_pos=textPos,
         text_fg=(1, 1, 1, 1),
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.37, 0, 0.2))
     cannonLabel = DirectLabel(parent=self.cannonLimit,
                               relief=None,
                               state=DGG.DISABLED,
                               text=PLocalizer.Cannon,
                               text_scale=0.036,
                               text_align=TextNode.ACenter,
                               text_pos=(0, 0.04),
                               text_fg=(1, 1, 1, 1),
                               text_shadow=(0, 0, 0, 1))
     self.cannonLabel = cannonLabel
     self.broadsideLimit = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=broadsideIcon,
         geom_scale=0.15,
         geom_pos=(0, 0, -0.05),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_pos=textPos,
         text_fg=(1, 1, 1, 1),
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.81, 0, 0.2))
     broadsideLabel = DirectLabel(parent=self.broadsideLimit,
                                  relief=None,
                                  state=DGG.DISABLED,
                                  text=PLocalizer.Broadsides,
                                  text_scale=0.036,
                                  text_align=TextNode.ACenter,
                                  text_fg=(1, 1, 1, 1),
                                  text_shadow=(0, 0, 0, 1),
                                  text_pos=(0.0, 0.04))
     self.broadsideLabel = broadsideLabel
     self.crewLimit = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         geom=crewIcon,
         geom_scale=0.4,
         geom_pos=(0, 0, 0.1),
         text='',
         text_scale=0.045,
         text_align=TextNode.ACenter,
         text_fg=(1, 1, 1, 1),
         text_shadow=(0, 0, 0, 1),
         textMayChange=1,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         pos=(0.56, 0, 0.04))
     crewLabel = DirectLabel(parent=self.crewLimit,
                             relief=None,
                             state=DGG.DISABLED,
                             text=PLocalizer.Crew,
                             text_scale=0.036,
                             text_align=TextNode.ACenter,
                             text_pos=(0.0, 0.2),
                             text_fg=(1, 1, 1, 1),
                             text_shadow=(0, 0, 0, 1))
     self.crewLabel = crewLabel
     shipOV = base.cr.getOwnerView(self.shipId)
     if shipOV:
         self.setShipName(shipOV.name)
         self.setShipClass(shipOV.shipClass)
         self.setShipHp(shipOV.Hp, shipOV.maxHp)
         self.setShipSp(shipOV.Sp, shipOV.maxSp)
         self.setShipCrew(shipOV.crew, shipOV.maxCrew)
         self.setShipCargo([], shipOV.maxCargo)
         if hasattr(shipOV, 'cannonConfig'):
             self.setShipMaxCannons(shipOV.cannonConfig)
             self.setShipMaxBroadside(shipOV.lBroadsideConfig,
                                      shipOV.rBroadsideConfig)
         self.updateIcons()
     if self.emptyBottle:
         self.hpMeter.hide()
         self.speedMeter.hide()
         self.plunderLimit.hide()
         self.cannonLimit.hide()
         self.broadsideLimit.hide()
         self.crewLimit.hide()
     self.accept('setName-%s' % self.shipId, self.setShipName)
     self.accept('setShipClass-%s' % self.shipId, self.setShipClass)
     self.accept('setShipHp-%s' % self.shipId, self.setShipHp)
     self.accept('setShipSp-%s' % self.shipId, self.setShipSp)
     self.accept('setShipCargo-%s' % self.shipId, self.setShipCargo)
     self.accept('setShipCrew-%s' % self.shipId, self.setShipCrew)
     self.accept('setShipTimer-%s' % self.shipId, self.setShipTimer)
     self.accept('setHullCannonConfig-%s' % self.shipId,
                 self.setShipMaxCannons)
     self.accept('setHullLeftBroadsideConfig-%s' % self.shipId,
                 self.setShipMaxLeftBroadside)
     self.accept('setHullRightBroadsideConfig-%s' % self.shipId,
                 self.setShipMaxRightBroadside)
     self.accept('ShipChanged-%s' % self.shipId, self.handleShipChanged)
     if base.config.GetBool('want-deploy-button', 0):
         pass
     return
    def _createIface(self):
        self.descText = DirectLabel(
            parent=self,
            relief=None,
            text=self.item.get('Text'),
            text_align=TextNode.ALeft,
            text_scale=0.050000000000000003,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            textMayChange=1,
            pos=(0.02, 0, self.height / 2),
            text_font=PiratesGlobals.getInterfaceOutlineFont())
        self.valueText = DirectLabel(
            parent=self,
            relief=None,
            text=str(self.item.get('Value1')),
            text_align=TextNode.ALeft,
            text_scale=0.050000000000000003,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            textMayChange=1,
            pos=(self.width * 0.65000000000000002, 0, self.height / 2),
            text_font=PiratesGlobals.getInterfaceOutlineFont())
        if self.item.get('Type') == 'Title':
            self.descText['text_scale'] = 0.055
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG1
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.valueText['text_scale'] = 0.044999999999999998
            self.valueText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            if self.item.has_key('Value2'):
                self.valueText2 = DirectLabel(
                    parent=self,
                    relief=None,
                    text=str(self.item.get('Value2')),
                    text_align=TextNode.ALeft,
                    text_scale=0.050000000000000003,
                    text_fg=PiratesGuiGlobals.TextFG2,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    textMayChange=1,
                    pos=(self.width * 0.80000000000000004, 0, self.height / 2),
                    text_font=PiratesGlobals.getInterfaceOutlineFont())

            if self.valueText2:
                self.valueText2['text_scale'] = 0.044999999999999998
                self.valueText2[
                    'text_font'] = PiratesGlobals.getInterfaceOutlineFont()

        elif self.item.get('Type') == 'Entry':
            self.descText['text_pos'] = (self.width * 0.059999999999999998, 0,
                                         0)
            if self.item.has_key('Value2'):
                self.valueText2 = DirectLabel(
                    parent=self,
                    relief=None,
                    text=str(self.item.get('Value2')),
                    text_align=TextNode.ALeft,
                    text_scale=0.050000000000000003,
                    text_fg=PiratesGuiGlobals.TextFG2,
                    text_shadow=PiratesGuiGlobals.TextShadow,
                    textMayChange=1,
                    pos=(self.width * 0.80000000000000004, 0, self.height / 2),
                    text_font=PiratesGlobals.getInterfaceOutlineFont())

        elif self.item.get('Type') == 'Space':
            self.descText['text_scale'] = 0.02
            self.descText['text'] = ' '
            self.valueText['text_scale'] = 0.02
            self.valueText['text'] = ' '
        elif self.item.get('Type') == 'Button':
            self.descText['text_pos'] = (self.width * 0.059999999999999998, 0,
                                         0)
            self.valueText['text'] = ' '
            self.button = DirectButton(
                parent=self,
                relief=DGG.RIDGE,
                text=self.item.get('Text'),
                text_align=TextNode.ALeft,
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_fg=PiratesGuiGlobals.TextFG1,
                text_shadow=PiratesGuiGlobals.TextShadow,
                frameColor=PiratesGuiGlobals.ButtonColor1,
                command=self.item.get('Value2'),
                pos=(self.width * 0.65000000000000002, 0, self.height / 2),
                borderWidth=(0.01, 0.01),
                pad=(0.0050000000000000001, 0.0050000000000000001),
                textMayChange=1)
            if self.item.get('State') == 'off':
                self.button['state'] = DGG.DISABLED
                self.button['text_fg'] = PiratesGuiGlobals.TextFG3
            elif self.item.get('State') == 'oneShot':
                self.button.bind(DGG.B1RELEASE, self.disableButton)

        elif self.item.get('Type') == 'Cargo':
            itemId = self.item.get('Value1')
            iconId = EconomyGlobals.getCargoCategory(itemId)
            if not iconId:
                self.notify.error('Invalid Item in Cargo! item: %s' %
                                  (self.item, ))

            icon = self.icons.get(iconId)
            self.descText['geom'] = self.getCargoIcon(icon[0], icon[1])
            self.descText[
                'geom_scale'] = 0.089999999999999997 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = icon[2]
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = PLocalizer.UnknownGoldValue
            self.valueText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.valueText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            icon = self.icons.get(ItemId.CARGO_CRATE)
            self.descText2 = DirectLabel(
                parent=self,
                relief=None,
                text='?',
                text_align=TextNode.ACenter,
                text_scale=0.050000000000000003 * self.height * 10,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                textMayChange=1,
                pos=(0.080000000000000002, 0, self.height / 2),
                geom=self.getCargoIcon(icon[0], icon[1]),
                geom_scale=0.089999999999999997 * self.height * 10,
                geom_pos=(0.10000000000000001, 0, 0.01),
                text_pos=(0.10000000000000001, 0, 0),
                geom_color=Vec4(0, 0, 0, 1),
                text_font=PiratesGlobals.getInterfaceOutlineFont())
        elif self.item.get('Type') == 'Gold':
            amount = self.item.get('Value2')
            itemName = PLocalizer.LootGold % amount
            self.descText['geom'] = self.getGoldIcon()
            self.descText[
                'geom_scale'] = 0.14999999999999999 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ' '
        elif self.item.get('Type') == 'LootGold':
            amount = self.item.get('Amount')
            itemName = PLocalizer.PlunderGold
            self.descText['geom'] = self.getGoldIcon()
            self.descText[
                'geom_scale'] = 0.28000000000000003 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = '%s' % amount
        elif self.item.get('Type') == 'MaterialText':
            amount = self.item.get('Amount')
            itemName = PLocalizer.LootShare
            self.descText['geom'] = None
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ''
        elif self.item.get('Type') == 'FreeMaterialRate':
            amount = self.item.get('Amount')
            itemName = PLocalizer.LimitedShare
            self.descText['geom'] = None
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ''
        elif self.item.get('Type') == 'PaidMaterialRate':
            amount = self.item.get('Amount')
            itemName = PLocalizer.UnlimitedShare
            self.descText['geom'] = None
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ''
        elif self.item.get('Type') == 'ShipMaterial':
            amount = self.item.get('Amount')
            typeId = self.item.get('Value1')
            itemName = PLocalizer.InventoryTypeNames.get(typeId, 'No Name')
            self.descText['geom'] = self.getMaterialIcon(typeId)
            self.descText[
                'geom_scale'] = 0.080000000000000002 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = '%s' % amount
        elif self.item.get('Type') == 'Weapon':
            itemId = self.item.get('Value1')
            itemName = PLocalizer.InventoryTypeNames.get(itemId)
            iconName = EconomyGlobals.getItemIcons(itemId)
            self.descText['geom'] = self.getWeaponIcon(iconName)
            self.descText[
                'geom_scale'] = 0.089999999999999997 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ' '
        elif self.item.get('Type') == 'Ammo':
            itemId = self.item.get('Value1')
            amount = self.item.get('Value2')
            itemName = '%s %s' % (amount,
                                  PLocalizer.InventoryTypeNames.get(itemId))
            iconName = WeaponGlobals.getSkillIcon(itemId)
            self.descText['geom'] = self.getAmmoIcon(iconName)
            self.descText[
                'geom_scale'] = 0.089999999999999997 * self.height * 10
            self.descText['geom_pos'] = (0.050000000000000003, 0, 0.01)
            self.descText['text_pos'] = (0.23999999999999999, 0, 0)
            self.descText['text'] = itemName
            self.descText['text_fg'] = PiratesGuiGlobals.TextFG2
            self.descText[
                'text_font'] = PiratesGlobals.getInterfaceOutlineFont()
            self.descText[
                'text_scale'] = 0.050000000000000003 * self.height * 10
            self.descText.setTransparency(1)
            self.valueText['text'] = ' '
 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
     
     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*')
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     border = 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.TextFG24
     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 = PLocalizer.InventoryItemClassNames.get(EconomyGlobals.getItemType(self.getId()), ''), 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)
     self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(self.getSkillId())), pos = (0.0, 2.5, 0.0))
     iHeight = 0.17999999999999999
     self.createBuffer()
     self.itemCard.setZ(runningVertPosition - 0.059999999999999998)
     runningVertPosition -= iHeight
     runningSize += iHeight
     labels.append(self.itemCard)
     description = PLocalizer.WeaponDescriptions.get(self.getId())
     if not description:
         description = PLocalizer.WeaponDescriptions.get(self.getSkillId())
     
     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)
     
     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)
Exemple #28
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