def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup, command = self.setPage, extraArgs = [
         itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item:
         pass
     elif repId or ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, image = icon, image_scale = 0.40000000000000002, image_pos = (0, 0, 0.040000000000000001), pos = (0.059999999999999998, 0, -0.035000000000000003))
     self.pageNames.append(itemGroup)
Example #2
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
Example #3
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
 def createGui(self):
     item, quantity = self.data
     name = PLocalizer.InventoryTypeNames[item]
     self.price = EconomyGlobals.getItemCost(item)
     repId = InventoryType.SailingRep
     itemTypeName = PLocalizer.InventoryTypeNames.get(repId)
     self.itemType = itemTypeName
     if self.sell:
         self.price /= 2
     card = loader.loadModel('models/textureCards/shipCatalog')
     renderName = self.shipImageDict.get(item, 'Catalog_War_Brig')
     myTexCard = card.find('**/%s*' % renderName)
     myTex = myTexCard.findAllTextures()[0]
     card.removeNode()
     del card
     self.minLvl = EconomyGlobals.getItemMinLevel(item)
     self.miscText = None
     self.picture = DirectFrame(parent=self, relief=None, state=DGG.DISABLED, image=myTex, image_scale=(0.07,
                                                                                                        1.0,
                                                                                                        0.06))
     self.picture.setPos(0.1, 0, 0.08)
     self.picture.setTransparency(1)
     self.nameTag = DirectLabel(parent=self, state=DGG.DISABLED, relief=None, text=name, text_scale=PiratesGuiGlobals.TextScaleMed * PLocalizer.getHeadingScale(2), text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=0)
     self.nameTag.setPos(0.2, 0, 0.1)
     self.costText = DirectLabel(parent=self, relief=None, state=DGG.DISABLED, geom=self.coinImage, geom_scale=0.12, geom_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.03, 0, 0), text_font=PiratesGlobals.getInterfaceFont())
     self.costText.setPos(0.48, 0, 0.04)
     return
Example #5
0
 def loadData(self):
     itemId = self.data[0]
     item, quantity = self.data
     self.quantity = quantity
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND:
         itemTypeName = PLocalizer.getItemSubtypeName(
             ItemGlobals.getSubtype(itemId))
     else:
         itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         name = PLocalizer.getItemName(itemId)
         self.price = ItemGlobals.getGoldCost(itemId)
     else:
         name = PLocalizer.InventoryTypeNames.get(item)
         self.price = EconomyGlobals.getItemCost(item)
     if self.sell:
         self.price /= 2
     if self.buy:
         if itemType > ItemType.WAND and itemType != ItemType.POTION:
             self.quantity = EconomyGlobals.getItemQuantity(itemId)
         self.price *= self.quantity
         self.price = int(self.price)
     self.name = PLocalizer.makeHeadingString(name, 2)
     self.itemType = itemTypeName
     if itemType != ItemType.FISHING_LURE:
         if itemType != ItemType.POTION:
             self.minLvl = ItemGlobals.getWeaponRequirement(itemId)
         else:
             self.minLvl = 0
     else:
         self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
 def loadData(self):
     itemId = self.data[0]
     (item, quantity) = self.data
     self.quantity = quantity
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND:
         itemTypeName = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     else:
         itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         name = PLocalizer.getItemName(itemId)
         self.price = ItemGlobals.getGoldCost(itemId)
     else:
         name = PLocalizer.InventoryTypeNames.get(item)
         self.price = EconomyGlobals.getItemCost(item)
     if self.sell:
         self.price /= 2
     
     if self.buy:
         if itemType > ItemType.WAND and itemType != ItemType.POTION:
             self.quantity = EconomyGlobals.getItemQuantity(itemId)
         
         self.price *= self.quantity
         self.price = int(self.price)
     
     self.name = PLocalizer.makeHeadingString(name, 2)
     self.itemType = itemTypeName
     if itemType != ItemType.FISHING_LURE:
         if itemType != ItemType.POTION:
             self.minLvl = ItemGlobals.getWeaponRequirement(itemId)
         else:
             self.minLvl = 0
     else:
         self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
Example #7
0
 def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup,
                                 command=self.setPage,
                                 extraArgs=[itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item < InventoryType.end_Consumables or ItemGlobals.getClass(
             item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item < InventoryType.end_WeaponCannonAmmo:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item < InventoryType.end_WeaponGrenadeAmmo:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item < InventoryType.end_FishingLures:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent=newTab,
                                  relief=None,
                                  state=DGG.DISABLED,
                                  image=icon,
                                  image_scale=0.4,
                                  image_pos=(0, 0, 0.04),
                                  pos=(0.06, 0, -0.035))
     self.pageNames.append(itemGroup)
     return
Example #8
0
 def sortData(a, b):
     aId = a.getData()[0]
     bId = b.getData()[0]
     aType = EconomyGlobals.getItemType(aId)
     bType = EconomyGlobals.getItemType(bId)
     if aType == bType:
         if aType <= ItemType.WAND or aType == ItemType.POTION:
             aSubtype = ItemGlobals.getSubtype(aId)
             bSubtype = ItemGlobals.getSubtype(bId)
             if aSubtype == bSubtype:
                 if aType <= ItemType.WAND:
                     aLevel = ItemGlobals.getWeaponRequirement(aId)
                     bLevel = ItemGlobals.getWeaponRequirement(bId)
                     if aLevel == bLevel:
                         if a.price == b.price:
                             if aId > bId:
                                 return 1
                             else:
                                 return -1
                         elif a.price > b.price:
                             return 1
                         else:
                             return -1
                     elif aLevel > bLevel:
                         return 1
                     else:
                         return -1
                 else:
                     aLevel = ItemGlobals.getNotorietyRequirement(aId)
                     bLevel = ItemGlobals.getNotorietyRequirement(bId)
                     if aLevel == bLevel:
                         if a.price == b.price:
                             if aId > bId:
                                 return 1
                             else:
                                 return -1
                         elif a.price > b.price:
                             return 1
                         else:
                             return -1
                     elif aLevel > bLevel:
                         return 1
                     else:
                         return -1
             elif aSubtype > bSubtype:
                 return 1
             else:
                 return -1
         elif aId > bId:
             return 1
         else:
             return -1
     else:
         if aType > bType:
             return 1
         else:
             return -1
Example #9
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
Example #10
0
 def sortData(a, b):
     aId = a.getData()[0]
     bId = b.getData()[0]
     aType = EconomyGlobals.getItemType(aId)
     bType = EconomyGlobals.getItemType(bId)
     if aType == bType:
         if aType <= ItemType.WAND or aType == ItemType.POTION:
             aSubtype = ItemGlobals.getSubtype(aId)
             bSubtype = ItemGlobals.getSubtype(bId)
             if aSubtype == bSubtype:
                 if aType <= ItemType.WAND:
                     aLevel = ItemGlobals.getWeaponRequirement(aId)
                     bLevel = ItemGlobals.getWeaponRequirement(bId)
                     if aLevel == bLevel:
                         if a.price == b.price:
                             if aId > bId:
                                 return 1
                             else:
                                 return -1
                         elif a.price > b.price:
                             return 1
                         else:
                             return -1
                     elif aLevel > bLevel:
                         return 1
                     else:
                         return -1
                 else:
                     aLevel = ItemGlobals.getNotorietyRequirement(aId)
                     bLevel = ItemGlobals.getNotorietyRequirement(bId)
                     if aLevel == bLevel:
                         if a.price == b.price:
                             if aId > bId:
                                 return 1
                             else:
                                 return -1
                         elif a.price > b.price:
                             return 1
                         else:
                             return -1
                     elif aLevel > bLevel:
                         return 1
                     else:
                         return -1
             elif aSubtype > bSubtype:
                 return 1
             else:
                 return -1
         elif aId > bId:
             return 1
         else:
             return -1
     elif aType > bType:
         return 1
     else:
         return -1
Example #11
0
    def createGui(self):
        (item, quantity) = self.data
        name = PLocalizer.InventoryTypeNames[item]
        self.price = EconomyGlobals.getItemCost(item)
        repId = InventoryType.SailingRep
        itemTypeName = PLocalizer.InventoryTypeNames.get(repId)
        self.itemType = itemTypeName
        if self.sell:
            self.price /= 2

        card = loader.loadModel("models/textureCards/shipCatalog")
        renderName = self.shipImageDict.get(item, "Catalog_War_Brig")
        myTexCard = card.find("**/%s*" % renderName)
        myTex = myTexCard.findAllTextures()[0]
        card.removeNode()
        del card
        self.minLvl = EconomyGlobals.getItemMinLevel(item)
        self.miscText = None
        self.picture = DirectFrame(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            image=myTex,
            image_scale=(0.070000000000000007, 1.0, 0.059999999999999998),
        )
        self.picture.setPos(0.10000000000000001, 0, 0.080000000000000002)
        self.picture.setTransparency(1)
        self.nameTag = DirectLabel(
            parent=self,
            state=DGG.DISABLED,
            relief=None,
            text=name,
            text_scale=PiratesGuiGlobals.TextScaleMed * PLocalizer.getHeadingScale(2),
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            textMayChange=0,
        )
        self.nameTag.setPos(0.20000000000000001, 0, 0.10000000000000001)
        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=self.coinImage,
            geom_scale=0.12,
            geom_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),
            text_font=PiratesGlobals.getInterfaceFont(),
        )
        self.costText.setPos(0.47999999999999998, 0, 0.040000000000000001)
Example #12
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.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()
Example #13
0
 def __init__(self, manager, skillId, itemTuple, imageScaleFactor = 1.0):
     InventoryUIItem.InventoryUIItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor)
     self.initialiseoptions(InventoryUIAmmoBagItem)
     weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
     fishingIcons = loader.loadModel('models/textureCards/fishing_icons')
     if self.itemTuple[1]:
         self['image'] = weaponIcons.find('**/%s' % EconomyGlobals.getItemIcons(self.itemTuple[1]))
     elif skillId == EconomyGlobals.ItemType.FISHING_POUCH:
         self['image'] = fishingIcons.find('**/%s' % EconomyGlobals.getItemTypeIcon(skillId))
     else:
         self['image'] = weaponIcons.find('**/%s' % EconomyGlobals.getItemTypeIcon(skillId))
     self.skillId = skillId
 def __init__(self, uid):
     SimpleEconomyItem.__init__(self, uid)
     self.icon = self.Icons.find('**/%s' % EconomyGlobals.getItemIcons(uid))
     if uid in range(InventoryType.begin_PistolPouches,
                     InventoryType.end_PistolPouches):
         self.shortDesc = PLocalizer.makeHeadingString(
             PLocalizer.InventoryItemClassNames.get(ItemType.PISTOL), 1)
     else:
         if uid in range(InventoryType.begin_DaggerPouches,
                         InventoryType.end_DaggerPouches):
             self.shortDesc = PLocalizer.makeHeadingString(
                 PLocalizer.InventoryItemClassNames.get(ItemType.DAGGER), 1)
         else:
             if uid in range(InventoryType.begin_GrenadePouches,
                             InventoryType.end_GrenadePouches):
                 self.shortDesc = PLocalizer.makeHeadingString(
                     PLocalizer.GrenadeShort, 1)
             else:
                 if uid in range(InventoryType.begin_CannonPouches,
                                 InventoryType.end_CannonPouches):
                     self.shortDesc = PLocalizer.makeHeadingString(
                         PLocalizer.ShipCannonShort, 1)
                 else:
                     self.shortDesc = PLocalizer.makeHeadingString(
                         self.itemType, 1)
     self.itemName = self.shortDesc
     self.longDesc = self.shortDesc
    def getItemRequirements(self, itemType, otherAdds=[]):
        if not itemType:
            return
        results = {}
        if game.process == 'client':
            paidStatus = Freebooter.getPaidStatus(self.ownerId)
        else:
            paidStatus = Freebooter.getPaidStatusAI(self.ownerId)
        rarity = ItemGlobals.getRarity(itemType)
        if rarity != ItemConstants.CRUDE and not paidStatus:
            results['paidStatus'] = (rarity != ItemConstants.CRUDE, False)
        itemClass = ItemGlobals.getClass(itemType)
        if itemClass == InventoryType.ItemTypeWeapon or itemClass == InventoryType.ItemTypeCharm:
            itemRepId = ItemGlobals.getItemRepId(itemType)
            itemRep = self.getReputation(itemRepId)
            itemLevel = ReputationGlobals.getLevelFromTotalReputation(
                itemRepId, itemRep)[0]
            weaponReq = ItemGlobals.getWeaponRequirement(itemType)
            trainingToken = EconomyGlobals.getItemTrainingReq(itemType)
            trainingAmt = self.getItemQuantity(trainingToken)
            for currAdd in otherAdds:
                otherAdd = InvItem(currAdd)
                if otherAdd.getCat(
                ) == trainingToken and otherAdd.getCount() > 0:
                    trainingAmt += otherAdd.getCount()

            weaponLevelPass = weaponReq == None or itemLevel >= weaponReq
            weaponTrainPass = trainingToken == 0 or trainingToken == None or trainingAmt > 0
            results['itemLevel'] = (weaponReq, weaponLevelPass
                                    and weaponTrainPass)
        else:
            results['itemLevel'] = (0, True)
        return results
 def __init__(self, manager, itemTuple, imageScaleFactor=1.0):
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
     self.initialiseoptions(InventoryUIPouchItem)
     Icons = loader.loadModel("models/gui/gui_icons_weapon")
     self["image"] = Icons.find("**/%s" % EconomyGlobals.getItemIcons(self.getId()))
     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
Example #17
0
    def confirmOverhaulShip(self, shipId=None):
        if not shipId:
            return None

        shipOV = self.cr.getOwnerView(shipId)
        if not shipOV:
            return None

        if shipOV.state != 'Off':
            base.localAvatar.guiMgr.createWarning(
                PLocalizer.ShipNotInBottleWarning, PiratesGuiGlobals.TextFG6)
            return None

        shipClass = shipOV.getShipClass()
        cost = EconomyGlobals.getItemCost(
            shipClass) * EconomyGlobals.OVERHAUL_COST_PERCENTAGE
        if self.confirmDialog:
            self.confirmDialog.destroy()
            self.confirmDialog = None

        self.confirmDialog = PDialog.PDialog(
            text=PLocalizer.OverhaulConfirmDialog % {'gold': cost},
            style=OTPDialog.YesNo,
            command=self.sendRequestOverhaulShip,
            extraArgs=[shipId])
 def getMissionResults(self):
     (missionTime, shipDamage, skeletonKills, navyKills, creatureKills, seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost, exp, gold, cargo, numCrew) = self.stats
     (pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills, pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills, pRepairCost, pExp, pGold, pCargo, pLootBoxes, dummyCrew) = self.playerStats
     inventory = base.localAvatar.getInventory()
     if inventory:
         currentGold = inventory.getGoldInPocket()
     
     t = time.gmtime(missionTime)
     totalTime = str(t[3]) + '"' + str(t[4]) + "'" + str(t[5])
     self.cargo = cargo
     cargoValue = EconomyGlobals.getCargoTotalValue(cargo)
     totalGold = max(cargoValue + gold - repairCost, 0)
     self.results = []
     self.results.append({
         'Type': 'Title',
         'Text': PLocalizer.PlunderedLootContainers,
         'Value1': '' })
     if len(pLootBoxes) == 0:
         self.results.append({
             'Type': 'Entry',
             'Text': PLocalizer.NoLootContainersPlundered,
             'Value1': '',
             'UnwrapMode': 1 })
     else:
         gold = 0
         height = self.plunderHeight
         for lootBox in pLootBoxes:
             plunderList = lootBox[1]
             gridText = self.getLootLabel(lootBox[2])
             self.makeLootLabel(gridText, self.plunderHeight)
             grid = self.setupPlunderGrid(plunderList, height, lootBox[0])
             grid.gridText = gridText
         
         self.manager.addScoreboard(self)
     return self.results
Example #19
0
    def updateBalance(self, extraArgs=None):
        self.balance = 0
        for item in self.purchaseInventory:
            self.balance += EconomyGlobals.getItemCost(item[0])

        if self.balance > 0:
            self.balanceTitle['text'] = PLocalizer.Cost
            self.balanceValue['text'] = str(abs(self.balance))
        elif self.balance < 0:
            self.balanceTitle['text'] = PLocalizer.Gain
            self.balanceValue['text'] = str(abs(self.balance))
        else:
            self.balanceTitle['text'] = PLocalizer.Cost
            self.balanceValue['text'] = str(abs(self.balance))
        inventory = base.localAvatar.getInventory()
        if inventory:
            if inventory.getGoldInPocket() < self.balance:
                self.commitButton[
                    'frameColor'] = PiratesGuiGlobals.ButtonColor3
            elif len(
                    inventory.getShipDoIdList()) >= inventory.getCategoryLimit(
                        InventoryCategory.SHIPS):
                self.commitButton[
                    'frameColor'] = PiratesGuiGlobals.ButtonColor3
            else:
                self.commitButton[
                    'frameColor'] = PiratesGuiGlobals.ButtonColor4
Example #20
0
 def __init__(self, manager, itemId, itemTuple, imageScaleFactor=1.0, showMax=1, update=False):
     self.itemId = itemId
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor=imageScaleFactor, showMax=showMax, update=update)
     self.initialiseoptions(InventoryUIMaterialItem)
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     MaterialIcons = loader.loadModel('models/textureCards/shipMaterialIcons')
     self['image'] = MaterialIcons.find('**/%s' % EconomyGlobals.getItemIcons(itemId))
     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
 def sendRequestSellShip(self, shipId, choice):
     shipOV = self.cr.getOwnerView(shipId)
     if not shipOV:
         if self.pickShipGUI:
             self.pickShipGUI.hide()
         
         return None
     
     modelType = ShipGlobals.getModelClass(shipOV.shipClass)
     cost = EconomyGlobals.getItemCost(modelType) / 2
     if choice == 1:
         inventory = base.localAvatar.getInventory()
         if inventory:
             if cost > 0 and inventory.getGoldInPocket() + cost > InventoryGlobals.GOLD_CAP:
                 r = Functor(self.sendRequestSellShipGoldOverflow, shipId)
                 if self.confirmDialog:
                     self.confirmDialog.destroy()
                     self.confirmDialog = None
                 
                 self.confirmDialog = PDialog.PDialog(text = PLocalizer.ExcessGoldLost, style = OTPDialog.YesNo, command = r)
                 return None
             
         
         self.sendUpdate('requestSellShip', [
             shipId])
     
     if self.pickShipGUI:
         self.pickShipGUI.hide()
     
     self.finishShopping()
 def __init__(self, manager, itemId, itemTuple, imageScaleFactor = 1.0, showMax = 1, update = False):
     self.itemId = itemId
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor, showMax = showMax, update = update)
     self.initialiseoptions(InventoryUIMaterialItem)
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     MaterialIcons = loader.loadModel('models/textureCards/shipMaterialIcons')
     self['image'] = MaterialIcons.find('**/%s' % EconomyGlobals.getItemIcons(itemId))
     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
Example #23
0
 def __init__(self, manager, itemTuple, imageScaleFactor=1.0):
     InventoryUIStackItem.InventoryUIStackItem.__init__(
         self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
     self.initialiseoptions(InventoryUIPouchItem)
     Icons = loader.loadModel('models/gui/gui_icons_weapon')
     self['image'] = Icons.find('**/%s' %
                                EconomyGlobals.getItemIcons(self.getId()))
     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 sendRequestSellShip(self, shipId, choice):
        shipOV = self.cr.getOwnerView(shipId)
        if not shipOV:
            if self.pickShipGUI:
                self.pickShipGUI.hide()

            return None

        modelType = ShipGlobals.getModelClass(shipOV.shipClass)
        cost = EconomyGlobals.getItemCost(modelType) / 2
        if choice == 1:
            inventory = base.localAvatar.getInventory()
            if inventory:
                if cost > 0 and inventory.getGoldInPocket() + cost > InventoryGlobals.GOLD_CAP:
                    r = Functor(self.sendRequestSellShipGoldOverflow, shipId)
                    if self.confirmDialog:
                        self.confirmDialog.destroy()
                        self.confirmDialog = None

                    self.confirmDialog = PDialog.PDialog(text = PLocalizer.ExcessGoldLost, style = OTPDialog.YesNo, command = r)
                    return None


            self.sendUpdate('requestSellShip', [
                shipId])

        if self.pickShipGUI:
            self.pickShipGUI.hide()

        self.finishShopping()
Example #25
0
 def __init__(self, manager, materialType, itemTuple, imageScaleFactor=1.0):
     InventoryUIItem.InventoryUIItem.__init__(
         self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
     self.initialiseoptions(InventoryUIMaterialBagItem)
     materialIcons = loader.loadModel('models/gui/gui_icons_weapon')
     self['image'] = materialIcons.find(
         '**/%s' % EconomyGlobals.getItemIcons(materialType))
     self.materialType = materialType
Example #26
0
    def requestMakeShipSale(self, buying, selling, names):
        avatar = self.air.doId2do.get(self.air.getAvatarIdFromSender())

        if not avatar:
            return

        inventory = self.air.inventoryManager.getInventory(avatar.doId)

        if not inventory:
            self.notify.warning('Failed to get inventory for avatar %d!' %
                                avatar.doId)
            self.sendUpdateToAvatarId(avatar.doId, 'makeSaleResponse',
                                      [RejectCode.TIMEOUT])
            return

        if len(buying) == 0:
            self.notify.warning(
                'Failed to process ship sale; Received an empty list!')
            self.sendUpdateToAvatarId(avatar.doId, 'makeSaleResponse',
                                      [RejectCode.TIMEOUT])
            return

        itemData = buying[0]
        shipId = itemData[0]
        requiredGold = EconomyGlobals.getItemCost(shipId)
        if requiredGold > inventory.getGoldInPocket():

            self.air.logPotentialHacker(
                message='Attempted to make sale without sufficent gold',
                pirateGold=inventory.getGoldInPocket(),
                requiredGold=requiredGold)

            self.sendUpdateToAvatarId(avatar.doId, 'makeSaleResponse', [0])
            return

        resultCode = 0

        #TODO check if there is an open slot
        openSlot = False
        if not openSlot:
            resultCode = RejectCode.OVERFLOW

        if resultCode == 0:

            self.air.writeServerEvent('shop-transaction',
                                      transactionType='ship',
                                      shipId=shipId,
                                      name=names)

            inventory.setGoldInPocket(inventory.getGoldInPocket() -
                                      requiredGold)

            #TODO issue ship

        self.sendUpdateToAvatarId(avatar.doId, 'makeSaleResponse',
                                  [resultCode])
 def figureOutStackTypes(self):
     self.listOfItemLists = []
     for pouchType in orderedPouchTypes:
         ammoList = EconomyGlobals.getPouchAmmoList(pouchType)
         continue
         itemList = [ WeaponGlobals.getSkillIdForAmmoSkillId(ammoId) for ammoId in ammoList ]
         itemList.insert(0, pouchType)
         self.listOfItemLists.append(itemList)
     
     self.discoverPouches()
 def reveal(self, args = None):
     if self.item.get('Type') == 'Cargo':
         itemId = self.item.get('Value1')
         icon = self.icons.get(itemId)
         self.descText2['geom'] = self.getCargoIcon(icon[0])
         self.descText2['geom_color'] = Vec4(1, 1, 1, 1)
         value = EconomyGlobals.getCargoValue(itemId)
         self.descText['text'] = icon[1]
         self.descText2['text'] = ''
         self.valueText['text'] = str(value) + ' ' + PLocalizer.MoneyName
 def reveal(self, args=None):
     if self.item.get('Type') == 'Cargo':
         itemId = self.item.get('Value1')
         icon = self.icons.get(itemId)
         self.descText2['geom'] = self.getCargoIcon(icon[0])
         self.descText2['geom_color'] = Vec4(1, 1, 1, 1)
         value = EconomyGlobals.getCargoValue(itemId)
         self.descText['text'] = icon[1]
         self.descText2['text'] = ''
         self.valueText['text'] = str(value) + ' ' + PLocalizer.MoneyName
    def getMissionResults(self):
        (missionTime, shipDamage, skeletonKills, navyKills, creatureKills,
         seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost,
         exp, gold, cargo, numCrew) = self.stats
        (pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills,
         pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills,
         pRepairCost, pExp, pGold, pCargo, pLootBoxes,
         dummyCrew) = self.playerStats
        inventory = base.localAvatar.getInventory()
        if inventory:
            currentGold = inventory.getGoldInPocket()

        t = time.gmtime(missionTime)
        totalTime = str(t[3]) + '"' + str(t[4]) + "'" + str(t[5])
        self.cargo = cargo
        cargoValue = EconomyGlobals.getCargoTotalValue(cargo)
        totalGold = max(cargoValue + gold - repairCost, 0)
        self.results = []
        self.results.append({
            'Type': 'Title',
            'Text': PLocalizer.PlunderedLootContainers,
            'Value1': ''
        })
        if len(pLootBoxes) == 0:
            self.results.append({
                'Type': 'Entry',
                'Text': PLocalizer.NoLootContainersPlundered,
                'Value1': '',
                'UnwrapMode': 1
            })
        else:
            gold = 0
            height = 1.6499999999999999
            for lootBox in pLootBoxes:
                plunderList = lootBox[1]
                if lootBox[2] == PiratesGlobals.ITEM_SAC:
                    self.makeLootLabel(PLocalizer.LootContainerItemSac, height)
                elif lootBox[2] == PiratesGlobals.TREASURE_CHEST:
                    self.makeLootLabel(PLocalizer.LootContainerTreasureChest,
                                       height)
                elif lootBox[2] == PiratesGlobals.RARE_CHEST:
                    self.makeLootLabel(PLocalizer.LootContainerRareChest,
                                       height)

                height -= 0.029999999999999999
                ammoAmountIndex = 0
                self.setupPlunderGrid(plunderList, height, lootBox[0])
                plunderLength = len(plunderList)
                while plunderLength > 0:
                    height -= self.buttonSize
                    plunderLength -= 2
                height -= 0.10000000000000001

            self.manager.addScoreboard(self)
        return self.results
Example #31
0
 def createGui(self):
     itemId = self.data[0]
     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.16, 0, 0.105), text_font = PiratesGlobals.getInterfaceFont())
     if itemId in range(InventoryType.begin_PistolPouches, InventoryType.end_PistolPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.PISTOL), 1)
     elif itemId in range(InventoryType.begin_DaggerPouches, InventoryType.end_DaggerPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.DAGGER), 1)
     elif itemId in range(InventoryType.begin_GrenadePouches, InventoryType.end_GrenadePouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.GrenadeShort, 1)
     elif itemId in range(InventoryType.begin_CannonPouches, InventoryType.end_CannonPouches):
         self.itemTypeFormatted = PLocalizer.makeHeadingString(PLocalizer.ShipCannonShort, 1)
     else:
         self.itemTypeFormatted = PLocalizer.makeHeadingString(self.itemType, 1)
     self.itemTypeName = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.itemTypeFormatted, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.16, 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.16, 0, 0.025000000000000001))
     if self.minLvl > 0:
         repId = WeaponGlobals.getRepId(itemId)
         if repId:
             self.checkLevel(repId, self.minLvl)
         
     
     self.checkFreebooter(itemId, base.localAvatar.getDoId())
     trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
     if trainingReq:
         self.checkTrainingReq(trainingReq)
     
     if EconomyGlobals.getItemCategory(itemId) == ItemType.AMMO:
         skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
         self.checkSkillReq(skillId)
     
     self.checkInfamyReq(itemId)
     if self.buy:
         self.checkPlayerInventory(itemId)
     
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.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.065000000000000002), 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())
     
     geomParams = InventoryItemGui.getGeomParams(itemId)
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, geom = geomParams['geom'], geom_pos = geomParams['geom_pos'], geom_scale = geomParams['geom_scale'], pos = (0.01, 0, 0.01))
     self.flattenStrong()
Example #32
0
 def reveal(self, args = None):
     if self.item.get('Type') == 'Cargo':
         amount = self.item.get('Amount', 1)
         itemId = self.item.get('Value1')
         icon = self.icons.get(itemId)
         self.descText2['geom'] = self.getCargoIcon(icon[0], icon[1])
         self.descText2['geom_color'] = Vec4(1, 1, 1, 1)
         value = EconomyGlobals.getCargoValue(itemId)
         if amount > 1:
             self.descText['text'] = icon[2] + ' x%s' % amount
         else:
             self.descText['text'] = icon[2]
         self.descText2['text'] = ''
         self.valueText['text'] = str(int(value * amount)) + ' ' + PLocalizer.MoneyName
    def createGui(self):
        (item, quantity) = self.data
        name = PLocalizer.InventoryTypeNames[item]
        self.price = EconomyGlobals.getItemCost(item)
        repId = InventoryType.SailingRep
        itemTypeName = PLocalizer.InventoryTypeNames.get(repId)
        self.itemType = itemTypeName
        if self.sell:
            self.price /= 2

        card = loader.loadModel('models/textureCards/shipRenders')
        if item in [
            ItemId.INTERCEPTOR_L1,
            ItemId.INTERCEPTOR_L2,
            ItemId.INTERCEPTOR_L3]:
            myTexCard = card.find('**/Interceptor_Render*')
        elif item in [
            ItemId.MERCHANT_L1,
            ItemId.MERCHANT_L2,
            ItemId.MERCHANT_L3]:
            myTexCard = card.find('**/Merchant_Render*')
        elif item in [
            ItemId.WARSHIP_L1,
            ItemId.WARSHIP_L2,
            ItemId.WARSHIP_L3]:
            myTexCard = card.find('**/Warship_Render*')
        else:
            myTexCard = card.find('**/Warship_Render*')
        myTex = myTexCard.findAllTextures()[0]
        card.removeNode()
        del card
        self.minLvl = EconomyGlobals.getItemMinLevel(item)
        self.miscText = None
        self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, image = myTex, image_scale = 0.059999999999999998, pos = (0.085000000000000006, 0, 0.074999999999999997))
        self.picture.setTransparency(1)
        self.nameTag = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = name, text_scale = PiratesGuiGlobals.TextScaleMed * PLocalizer.getHeadingScale(2), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (0.16, 0, 0.105), textMayChange = 0)
        self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, geom = self.coinImage, geom_scale = 0.12, geom_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())
Example #34
0
 def __init__(self, uid):
     SimpleEconomyItem.__init__(self, uid)
     self.icon = self.Icons.find('**/%s' % EconomyGlobals.getItemIcons(uid))
     if uid in range(InventoryType.begin_PistolPouches, InventoryType.end_PistolPouches):
         self.shortDesc = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.PISTOL), 1)
     elif uid in range(InventoryType.begin_DaggerPouches, InventoryType.end_DaggerPouches):
         self.shortDesc = PLocalizer.makeHeadingString(PLocalizer.InventoryItemClassNames.get(ItemType.DAGGER), 1)
     elif uid in range(InventoryType.begin_GrenadePouches, InventoryType.end_GrenadePouches):
         self.shortDesc = PLocalizer.makeHeadingString(PLocalizer.GrenadeShort, 1)
     elif uid in range(InventoryType.begin_CannonPouches, InventoryType.end_CannonPouches):
         self.shortDesc = PLocalizer.makeHeadingString(PLocalizer.ShipCannonShort, 1)
     else:
         self.shortDesc = PLocalizer.makeHeadingString(self.itemType, 1)
     self.itemName = self.shortDesc
     self.longDesc = self.shortDesc
Example #35
0
 def reveal(self, args=None):
     if self.item.get('Type') == 'Cargo':
         amount = self.item.get('Amount', 1)
         itemId = self.item.get('Value1')
         icon = self.icons.get(itemId)
         self.descText2['geom'] = self.getCargoIcon(icon[0], icon[1])
         self.descText2['geom_color'] = Vec4(1, 1, 1, 1)
         value = EconomyGlobals.getCargoValue(itemId)
         if amount > 1:
             self.descText['text'] = icon[2] + ' x%s' % amount
         else:
             self.descText['text'] = icon[2]
         self.descText2['text'] = ''
         self.valueText['text'] = str(int(
             value * amount)) + ' ' + PLocalizer.MoneyName
Example #36
0
 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
 def sendRequestOverhaulShip(self, choice, extraArgs):
     if self.pickShipGUI:
         self.pickShipGUI.hide()
     shipId = extraArgs[0]
     shipOV = self.cr.getOwnerView(shipId)
     if not shipOV:
         return
     shipClass = shipOV.getShipClass()
     cost = EconomyGlobals.getItemCost(shipClass) * EconomyGlobals.OVERHAUL_COST_PERCENTAGE
     if choice == 1:
         inventory = base.localAvatar.getInventory()
         if inventory:
             if inventory.getGoldInPocket() < cost:
                 base.localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughMoneyWarning, PiratesGuiGlobals.TextFG6)
                 return
         self.sendUpdate('requestPurchaseOverhaul', [shipId])
     self.finishShopping()
 def getMissionResults(self):
     (missionTime, shipDamage, skeletonKills, navyKills, creatureKills, seamonsterKills, pirateKills, townfolkKills, shipKills, repairCost, exp, gold, cargo, numCrew) = self.stats
     (pMissionTime, pShipDamage, pSkeletonKills, pNavyKills, pCreatureKills, pSeamonsterKills, pPirateKills, pTownfolkKills, pShipKills, pRepairCost, pExp, pGold, pCargo, pLootBoxes, dummyCrew) = self.playerStats
     inventory = base.localAvatar.getInventory()
     if inventory:
         currentGold = inventory.getGoldInPocket()
     
     t = time.gmtime(missionTime)
     totalTime = str(t[3]) + '"' + str(t[4]) + "'" + str(t[5])
     self.cargo = cargo
     cargoValue = EconomyGlobals.getCargoTotalValue(cargo)
     totalGold = max(cargoValue + gold - repairCost, 0)
     self.results = []
     self.results.append({
         'Type': 'Title',
         'Text': PLocalizer.PlunderedLootContainers,
         'Value1': '' })
     if len(pLootBoxes) == 0:
         self.results.append({
             'Type': 'Entry',
             'Text': PLocalizer.NoLootContainersPlundered,
             'Value1': '',
             'UnwrapMode': 1 })
     else:
         gold = 0
         height = 1.6499999999999999
         for lootBox in pLootBoxes:
             plunderList = lootBox[1]
             if lootBox[2] == PiratesGlobals.ITEM_SAC:
                 self.makeLootLabel(PLocalizer.LootContainerItemSac, height)
             elif lootBox[2] == PiratesGlobals.TREASURE_CHEST:
                 self.makeLootLabel(PLocalizer.LootContainerTreasureChest, height)
             elif lootBox[2] == PiratesGlobals.RARE_CHEST:
                 self.makeLootLabel(PLocalizer.LootContainerRareChest, height)
             
             height -= 0.029999999999999999
             ammoAmountIndex = 0
             self.setupPlunderGrid(plunderList, height, lootBox[0])
             plunderLength = len(plunderList)
             while plunderLength > 0:
                 height -= self.buttonSize
                 plunderLength -= 2
             height -= 0.10000000000000001
         
         self.manager.addScoreboard(self)
     return self.results
 def confirmSellShip(self, shipId=None):
     if not shipId:
         return
     shipOV = self.cr.getOwnerView(shipId)
     if not shipOV:
         return
     if shipOV.state != 'Off':
         base.localAvatar.guiMgr.createWarning(PLocalizer.ShipNotInBottleWarning, PiratesGuiGlobals.TextFG6)
         return
     modelType = ShipGlobals.getModelClass(shipOV.shipClass)
     cost = EconomyGlobals.getItemCost(modelType) / 2
     r = Functor(self.doubleConfirmSellShip, shipId)
     if self.confirmDialog:
         self.confirmDialog.destroy()
         self.confirmDialog = None
     self.confirmDialog = PDialog.PDialog(text=PLocalizer.SellShipConfirmDialog % {'gold': cost}, style=OTPDialog.YesNo, command=r)
     return
Example #40
0
 def __init__(self, uid):
     self.uid = uid
     self.itemName = PLocalizer.getItemName(uid)
     self.shortDesc = PLocalizer.getItemName(uid)
     self.longDesc = PLocalizer.getItemFlavorText(uid)
     self.text = None
     self.modelId = None
     self.texId = None
     self.colorId = 0
     self.holidayId = None
     self.icon = None
     self.iconScale = 1.0
     self.iconHpr = (0, 0, 0)
     if self.checkStackable():
         self.quantity = EconomyGlobals.getItemQuantity(self.uid)
     else:
         self.quantity = 1
Example #41
0
 def __init__(self, uid):
     self.uid = uid
     self.itemName = PLocalizer.getItemName(uid)
     self.shortDesc = PLocalizer.getItemName(uid)
     self.longDesc = PLocalizer.getItemFlavorText(uid)
     self.text = None
     self.modelId = None
     self.texId = None
     self.colorId = 0
     self.holidayId = None
     self.icon = None
     self.iconScale = 1.0
     self.iconHpr = (0, 0, 0)
     if self.checkStackable():
         self.quantity = EconomyGlobals.getItemQuantity(self.uid)
     else:
         self.quantity = 1
    def confirmSellShip(self, shipId = None):
        if not shipId:
            return None

        shipOV = self.cr.getOwnerView(shipId)
        if not shipOV:
            return None

        if shipOV.state != 'Off':
            base.localAvatar.guiMgr.createWarning(PLocalizer.ShipNotInBottleWarning, PiratesGuiGlobals.TextFG6)
            return None

        modelType = ShipGlobals.getModelClass(shipOV.shipClass)
        cost = EconomyGlobals.getItemCost(modelType) / 2
        r = Functor(self.doubleConfirmSellShip, shipId)
        if self.confirmDialog:
            self.confirmDialog.destroy()
            self.confirmDialog = None

        self.confirmDialog = PDialog.PDialog(text = PLocalizer.SellShipConfirmDialog % {
            'gold': cost }, style = OTPDialog.YesNo, command = r)
    def confirmOverhaulShip(self, shipId = None):
        if not shipId:
            return None

        shipOV = self.cr.getOwnerView(shipId)
        if not shipOV:
            return None

        if shipOV.state != 'Off':
            base.localAvatar.guiMgr.createWarning(PLocalizer.ShipNotInBottleWarning, PiratesGuiGlobals.TextFG6)
            return None

        shipClass = shipOV.getShipClass()
        cost = EconomyGlobals.getItemCost(shipClass) * EconomyGlobals.OVERHAUL_COST_PERCENTAGE
        if self.confirmDialog:
            self.confirmDialog.destroy()
            self.confirmDialog = None

        self.confirmDialog = PDialog.PDialog(text = PLocalizer.OverhaulConfirmDialog % {
            'gold': cost }, style = OTPDialog.YesNo, command = self.sendRequestOverhaulShip, extraArgs = [
            shipId])
    def getItemRequirements(self, itemType, otherAdds = []):
        if not itemType:
            return None

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

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

            if not weaponReq == None:
                pass
            weaponLevelPass = itemLevel >= weaponReq
            if not trainingToken == 0 and trainingToken == None:
                pass
            weaponTrainPass = trainingAmt > 0
            if weaponLevelPass:
                pass
            results['itemLevel'] = (weaponReq, weaponTrainPass)
        else:
            results['itemLevel'] = (0, True)
        return results
 def loadData(self):
     itemId = self.data[0]
     if UberDogGlobals.InventoryId.isStackable(itemId):
         (item, quantity) = self.data
         name = PLocalizer.InventoryTypeNames.get(item)
         self.quantity = 1
         itemType = None
         itemTypeName = None
         self.price = 5
     else:
         (category, doId) = self.data
         name = PLocalizer.InventoryCategoryNames.get(category)
         self.quantity = 1
         itemTypeName = 'Object'
         self.price = 5
     if self.buy:
         self.price *= self.quantity
         self.price = int(self.price)
     
     self.name = PLocalizer.makeHeadingString(name, 2)
     self.itemType = itemTypeName
     self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
Example #46
0
 def updateBalance(self, extraArgs = None):
     self.balance = 0
     for item in self.purchaseInventory:
         self.balance += EconomyGlobals.getItemCost(item[0])
     
     if self.balance > 0:
         self.balanceTitle['text'] = PLocalizer.Cost
         self.balanceValue['text'] = str(abs(self.balance))
     elif self.balance < 0:
         self.balanceTitle['text'] = PLocalizer.Gain
         self.balanceValue['text'] = str(abs(self.balance))
     else:
         self.balanceTitle['text'] = PLocalizer.Cost
         self.balanceValue['text'] = str(abs(self.balance))
     inventory = base.localAvatar.getInventory()
     if inventory:
         if inventory.getGoldInPocket() < self.balance:
             self.commitButton['frameColor'] = PiratesGuiGlobals.ButtonColor3
         elif len(inventory.getShipDoIdList()) >= inventory.getCategoryLimit(InventoryCategory.SHIPS):
             self.commitButton['frameColor'] = PiratesGuiGlobals.ButtonColor3
         else:
             self.commitButton['frameColor'] = PiratesGuiGlobals.ButtonColor4
Example #47
0
    def loadData(self):
        itemId = self.data[0]
        if UberDogGlobals.InventoryId.isStackable(itemId):
            (item, quantity) = self.data
            name = PLocalizer.InventoryTypeNames.get(item)
            self.quantity = 1
            itemType = None
            itemTypeName = None
            self.price = 5
        else:
            (category, doId) = self.data
            name = PLocalizer.InventoryCategoryNames.get(category)
            self.quantity = 1
            itemTypeName = 'Object'
            self.price = 5
        if self.buy:
            self.price *= self.quantity
            self.price = int(self.price)

        self.name = PLocalizer.makeHeadingString(name, 2)
        self.itemType = itemTypeName
        self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
    def sendRequestOverhaulShip(self, choice, extraArgs):
        if self.pickShipGUI:
            self.pickShipGUI.hide()

        shipId = extraArgs[0]
        shipOV = self.cr.getOwnerView(shipId)
        if not shipOV:
            return None

        shipClass = shipOV.getShipClass()
        cost = EconomyGlobals.getItemCost(shipClass) * EconomyGlobals.OVERHAUL_COST_PERCENTAGE
        if choice == 1:
            inventory = base.localAvatar.getInventory()
            if inventory:
                if inventory.getGoldInPocket() < cost:
                    base.localAvatar.guiMgr.createWarning(PLocalizer.NotEnoughMoneyWarning, PiratesGuiGlobals.TextFG6)
                    return None


            self.sendUpdate('requestPurchaseOverhaul', [
                shipId])

        self.finishShopping()
 def setupItems(self, itemList):
     for itemId in itemList:
         itemClass = ItemGlobals.getClass(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         itemTuple = [
             itemClass,
             itemId,
             0,
             0]
         item = None
         if itemClass == InventoryType.ItemTypeWeapon:
             item = self.manager.makeWeaponItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeCharm:
             item = self.manager.makeCharmItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeConsumable:
             itemTuple[3] = 1
             item = self.manager.makeConsumableItem(itemTuple, showMax = 0)
         elif itemClass == InventoryType.ItemTypeClothing:
             item = self.manager.makeClothingItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeMoney:
             item = self.manager.makeGoldItem(itemTuple)
         elif itemClass == InventoryType.TreasureCollection:
             item = self.manager.makeTreasureItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeJewelry:
             item = self.manager.makeJewelryItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeTattoo:
             item = self.manager.makeTattooItem(itemTuple)
         elif itemClass == InventoryCategory.CARDS:
             cardId = itemId
             itemTuple[1] -= InventoryType.begin_Cards
             item = self.manager.makeCardItem(cardId, itemTuple, imageScaleFactor = 1.8999999999999999)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(itemId)
             item = self.manager.makeAmmoItem(itemId, itemTuple, showMax = 0)
         elif itemType in [
             EconomyGlobals.ItemType.DAGGERAMMO,
             EconomyGlobals.ItemType.PISTOLAMMO,
             EconomyGlobals.ItemType.GRENADEAMMO,
             EconomyGlobals.ItemType.CANNONAMMO]:
             itemTuple = [
                 0,
                 itemId,
                 0,
                 EconomyGlobals.getItemQuantity(itemId)]
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             item = self.manager.makeAmmoItem(skillId, itemTuple, showMax = 0)
         elif itemType in [
             EconomyGlobals.ItemType.PISTOL_POUCH,
             EconomyGlobals.ItemType.DAGGER_POUCH,
             EconomyGlobals.ItemType.GRENADE_POUCH,
             EconomyGlobals.ItemType.CANNON_POUCH,
             EconomyGlobals.ItemType.FISHING_POUCH]:
             item = self.manager.makePouchItem(itemTuple)
         elif itemType in (EconomyGlobals.ItemType.FISHING_LURE,):
             itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(itemId)
             itemTuple[3] = EconomyGlobals.getItemQuantity(itemId)
             item = self.manager.makeFishingItem(itemId, itemTuple, showMax = 0)
         
         if itemClass in (InventoryType.ItemTypeMoney, InventoryCategory.CARDS, InventoryType.TreasureCollection):
             self.addGridCell(self.stackImage, 1.0)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             self.addGridCell(self.stackImage2, 1.0)
         elif itemType in (EconomyGlobals.ItemType.FISHING_LURE,):
             self.addGridCell(self.stackImage, 1.0)
         else:
             self.addGridCell()
         if item:
             self.tryPutIntoFirstOpenCell(item)
         
         item.showResaleValue = False
         if self.zCount == self.gridZ:
             break
             
     
     while self.zCount < self.gridZ:
         self.addGridCell()
Example #50
0
    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 discoverPouches(self):
     for listOfSkills in self.listOfItemLists:
         pouchType = listOfSkills[0]
         possiblePouches = EconomyGlobals.getListOfPouches(pouchType)
         actualPouchId = self.findMaxPouchInUse(possiblePouches)
         self.subBagTypeToBagId[pouchType] = actualPouchId
Example #52
0
 def getMaterialIcon(self, itemId):
     card = loader.loadModel('models/textureCards/shipMaterialIcons')
     icon = card.find('**/%s' % EconomyGlobals.getItemIcons(itemId))
     card.removeNode()
     del card
     return icon
 def discoverPouches(self):
     for listOfSkills in self.listOfItemLists:
         pouchType = listOfSkills[0]
         possiblePouches = EconomyGlobals.getListOfPouches(pouchType)
         actualPouchId = self.findMaxPouchInUse(possiblePouches)
         self.subBagTypeToBagId[pouchType] = actualPouchId
Example #54
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)
 def __init__(self, manager, materialType, itemTuple, imageScaleFactor = 1.0):
     InventoryUIItem.InventoryUIItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor)
     self.initialiseoptions(InventoryUIMaterialBagItem)
     materialIcons = loader.loadModel('models/gui/gui_icons_weapon')
     self['image'] = materialIcons.find('**/%s' % EconomyGlobals.getItemIcons(materialType))
     self.materialType = materialType
 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)
     MaterialIcons = loader.loadModel('models/textureCards/shipMaterialIcons')
     self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = MaterialIcons.find('**/%s' % EconomyGlobals.getItemIcons(self.getItemId())), 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.getItemId())
     
     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)