示例#1
0
 def loadGui(self):
     self.dummyFrame = DirectFrame(parent=self,
                                   relief=None,
                                   pos=(-0.42999999999999999, 0,
                                        1.3799999999999999),
                                   sortOrder=-1000)
     self.skillRingFrame = SkillRing(color=Vec4(1, 1, 0, 1))
     self.skillRingFrame.reparentTo(self.dummyFrame)
     self.skillRingFrame.setPos(-0.089999999999999997, 0,
                                -0.029999999999999999)
     self.skillIconFrame = DirectFrame(parent=self.skillRingFrame,
                                       pos=(0, 0, 0),
                                       relief=None,
                                       image=self.skillIcon,
                                       image_scale=(0.14000000000000001, 1,
                                                    0.14000000000000001))
     self.buffTitle = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(-0.16, 0, 0.080000000000000002),
         text=PLocalizer.CrewBuffCaptainOrder,
         text_align=TextNode.ALeft,
         text_scale=0.050000000000000003,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG13,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
     self.buffNameFrame = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(0.0, 0, 0.0),
         text=self.buffName,
         text_align=TextNode.ALeft,
         text_scale=0.047,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG1,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
     self.buffDescFrame = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(0.0, 0, -0.044999999999999998),
         text=self.buffDesc,
         text_align=TextNode.ALeft,
         text_scale=0.036999999999999998,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG2,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
示例#2
0
 def __init__(self, data, **kw):
     (self.skillId, self.amt) = data
     self.button = None
     self.loadGui()
     DirectFrame.__init__(self)
     self.initialiseoptions(TonicsPanel)
     self.skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1),
                                Vec4(0, 0, 0, 1.0))
     self.skillRing.reparentTo(self)
     self.skillRing.setPos(0, 0, 0)
     self.setSkillId(self.skillId)
     self.greyOut = 0
示例#3
0
 def loadGui(self):
     self.dummyFrame = DirectFrame(parent = self, relief = None, pos = (-0.42999999999999999, 0, 1.3799999999999999), sortOrder = -1000)
     self.skillRingFrame = SkillRing(color = Vec4(1, 1, 0, 1))
     self.skillRingFrame.reparentTo(self.dummyFrame)
     self.skillRingFrame.setPos(-0.089999999999999997, 0, -0.029999999999999999)
     self.skillIconFrame = DirectFrame(parent = self.skillRingFrame, pos = (0, 0, 0), relief = None, image = self.skillIcon, image_scale = (0.14000000000000001, 1, 0.14000000000000001))
     self.buffTitle = DirectFrame(parent = self.dummyFrame, relief = None, pos = (-0.16, 0, 0.080000000000000002), text = PLocalizer.CrewBuffCaptainOrder, text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG13, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
     self.buffNameFrame = DirectFrame(parent = self.dummyFrame, relief = None, pos = (0.0, 0, 0.0), text = self.buffName, text_align = TextNode.ALeft, text_scale = 0.047, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
     self.buffDescFrame = DirectFrame(parent = self.dummyFrame, relief = None, pos = (0.0, 0, -0.044999999999999998), text = self.buffDesc, text_align = TextNode.ALeft, text_scale = 0.036999999999999998, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
 def __init__(self, data, **kw):
     (self.skillId, self.amt) = data
     self.button = None
     self.loadGui()
     DirectFrame.__init__(self)
     self.initialiseoptions(TonicsPanel)
     self.skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     self.skillRing.reparentTo(self)
     self.skillRing.setPos(0, 0, 0)
     self.setSkillId(self.skillId)
     self.greyOut = 0
class TonicsPanel(DirectFrame):
    width = PiratesGuiGlobals.InventoryInfoWidth
    height = PiratesGuiGlobals.InventoryInfoHeight
    guiLoaded = False
    topGui = None
    weaponIcons = None
    skillIcons = None
    
    def __init__(self, data, **kw):
        (self.skillId, self.amt) = data
        self.button = None
        self.loadGui()
        DirectFrame.__init__(self)
        self.initialiseoptions(TonicsPanel)
        self.skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
        self.skillRing.reparentTo(self)
        self.skillRing.setPos(0, 0, 0)
        self.setSkillId(self.skillId)
        self.greyOut = 0

    
    def loadGui(self):
        if TonicsPanel.guiLoaded:
            return None
        
        TonicsPanel.topGui = loader.loadModel('models/gui/toplevel_gui')
        TonicsPanel.weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        TonicsPanel.skillIcons = loader.loadModel('models/textureCards/skillIcons')
        TonicsPanel.guiLoaded = True

    
    def setSkillId(self, skillId):
        self.skillId = skillId
        if self.button:
            self.button.destroy()
        
        self.button = SkillpageGuiButton.SkillpageGuiButton(self.callback, self.skillId, 0)
        self.button['geom_scale'] = 0.089999999999999997
        self.button.reparentTo(self)
        self.button.resetFrameSize()
        self.button.attachQuantity(self.amt)

    
    def destroy(self):
        DirectFrame.destroy(self)

    
    def callback(self, skillId):
        localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0)

    
    def updateQuantity(self, amt):
        self.amt = amt
        if self.button:
            self.button.attachQuantity(amt)
        

    
    def update(self, task = None):
        inv = localAvatar.getInventory()
        if not inv:
            return Task.cont
        
        greyOut = 0
        amt = inv.getStackQuantity(self.skillId)
        if amt <= 0:
            greyOut = 1
        
        if amt != self.amt:
            self.amt = amt
            self.button.attachQuantity(amt)
        
        range = localAvatar.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem)
        value = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem)
        if not value:
            value = range
        
        self.skillRing.update(value, range)
        if value < range:
            greyOut = 3
        
        if self.greyOut != greyOut:
            self.greyOut = greyOut
            if greyOut == 2:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
            elif greyOut == 1:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
                self.skillRing.meterFaceHalf1.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
                self.skillRing.meterFaceHalf2.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
            elif greyOut == 3:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
            else:
                self.button['geom_color'] = Vec4(1, 1, 1, 1)
                self.skillRing.meterFaceHalf1.setColorScale(1, 1, 1, 1.0)
                self.skillRing.meterFaceHalf2.setColorScale(1, 1, 1, 1.0)
        
        return Task.cont
示例#6
0
class CrewBuffDisplay(DirectFrame):
    __module__ = __name__

    def __init__(self,
                 parent,
                 skillIcon=None,
                 duration=10,
                 buffName='',
                 buffDesc='',
                 **kw):
        DirectFrame.__init__(self, parent, **kw)
        self.dummyFrame = None
        self.skillRingFrame = None
        self.skillIconFrame = None
        self.buffNameFrame = None
        self.buffDescFrame = None
        self.buffTitle = None
        self.skillIcon = skillIcon
        self.duration = duration
        self.currTime = duration
        self.buffName = buffName
        self.buffDesc = buffDesc
        self.skillRingIval = None
        self.runInIval = None
        self.loadGui()
        return

    def destroy(self):
        self.ignoreAll()
        if self.skillRingFrame:
            self.skillRingFrame.destroy()
            self.skillRingFrame = None
        if self.skillIconFrame:
            self.skillIconFrame.destroy()
            self.skillIconFrame = None
        if self.buffNameFrame:
            self.buffNameFrame.destroy()
            self.buffNameFrame = None
        if self.buffDescFrame:
            self.buffDescFrame.destroy()
            self.buffDescFrame = None
        if self.buffTitle:
            self.buffTitle.destroy()
            self.buffTitle = None
        if self.dummyFrame:
            self.dummyFrame.destroy()
            self.dummyFrame = None
        DirectFrame.destroy(self)
        return

    def loadGui(self):
        self.dummyFrame = DirectFrame(parent=self,
                                      relief=None,
                                      pos=(-0.43, 0, 1.38),
                                      sortOrder=-1000)
        self.skillRingFrame = SkillRing(color=Vec4(1, 1, 0, 1))
        self.skillRingFrame.reparentTo(self.dummyFrame)
        self.skillRingFrame.setPos(-0.09, 0, -0.03)
        self.skillIconFrame = DirectFrame(parent=self.skillRingFrame,
                                          pos=(0, 0, 0),
                                          relief=None,
                                          image=self.skillIcon,
                                          image_scale=(0.14, 1, 0.14))
        self.buffTitle = DirectFrame(
            parent=self.dummyFrame,
            relief=None,
            pos=(-0.16, 0, 0.08),
            text=PLocalizer.CrewBuffCaptainOrder,
            text_align=TextNode.ALeft,
            text_scale=0.05,
            text_pos=(0, 0),
            text_fg=PiratesGuiGlobals.TextFG13,
            text_wordwrap=15,
            text_shadow=(0, 0, 0, 1),
            textMayChange=0,
            text_font=PiratesGlobals.getInterfaceFont())
        self.buffNameFrame = DirectFrame(
            parent=self.dummyFrame,
            relief=None,
            pos=(0.0, 0, 0.0),
            text=self.buffName,
            text_align=TextNode.ALeft,
            text_scale=0.047,
            text_pos=(0, 0),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_wordwrap=15,
            text_shadow=(0, 0, 0, 1),
            textMayChange=0,
            text_font=PiratesGlobals.getInterfaceFont())
        self.buffDescFrame = DirectFrame(
            parent=self.dummyFrame,
            relief=None,
            pos=(0.0, 0, -0.045),
            text=self.buffDesc,
            text_align=TextNode.ALeft,
            text_scale=0.037,
            text_pos=(0, 0),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_wordwrap=15,
            text_shadow=(0, 0, 0, 1),
            textMayChange=0,
            text_font=PiratesGlobals.getInterfaceFont())
        return

    def createSkillRingIval(self):
        self.skillRingIval = Sequence(
            Func(self.skillRingFrame.meterFaceHalf1.setColor,
                 self.skillRingFrame.meterActiveColor, 100),
            Func(self.skillRingFrame.meterFaceHalf2.setColor,
                 self.skillRingFrame.meterActiveColor, 100),
            Func(self.skillRingFrame.meterFaceHalf1.setR, -180),
            Func(self.skillRingFrame.meterFaceHalf2.setR, 0),
            Func(self.skillRingFrame.meterFaceHalf1.show),
            Func(self.skillRingFrame.meterFaceHalf2.show),
            LerpFunc(self.skillRingFrame.meterFaceHalf2.setR,
                     self.duration / 2, 0, 180),
            Func(self.skillRingFrame.meterFaceHalf2.setColor, Vec4(0, 0, 0, 1),
                 100), Func(self.skillRingFrame.meterFaceHalf2.setR, 0),
            LerpFunc(self.skillRingFrame.meterFaceHalf1.setR,
                     self.duration / 2, -180, 0), Func(self.hide))

    def play(self):
        if not self.runInIval:
            self.runInIval = self.dummyFrame.posInterval(0.4,
                                                         Vec3(-0.43, 0, 1.38),
                                                         startPos=Vec3(
                                                             0.0, 0, 1.38))
        self.runInIval.start()
        if not self.skillRingIval:
            self.createSkillRingIval()
        if self.skillRingIval:
            self.skillRingIval.start()

    def stop(self):
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRingIval = None
        if self.runInIval:
            self.runInIval.pause()
            self.runInIval = None
        return
示例#7
0
class TonicsPanel(DirectFrame):
    width = PiratesGuiGlobals.InventoryInfoWidth
    height = PiratesGuiGlobals.InventoryInfoHeight
    guiLoaded = False
    topGui = None
    weaponIcons = None
    skillIcons = None

    def __init__(self, data, **kw):
        (self.skillId, self.amt) = data
        self.button = None
        self.loadGui()
        DirectFrame.__init__(self)
        self.initialiseoptions(TonicsPanel)
        self.skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1),
                                   Vec4(0, 0, 0, 1.0))
        self.skillRing.reparentTo(self)
        self.skillRing.setPos(0, 0, 0)
        self.setSkillId(self.skillId)
        self.greyOut = 0

    def loadGui(self):
        if TonicsPanel.guiLoaded:
            return None

        TonicsPanel.topGui = loader.loadModel('models/gui/toplevel_gui')
        TonicsPanel.weaponIcons = loader.loadModel(
            'models/gui/gui_icons_weapon')
        TonicsPanel.skillIcons = loader.loadModel(
            'models/textureCards/skillIcons')
        TonicsPanel.guiLoaded = True

    def setSkillId(self, skillId):
        self.skillId = skillId
        if self.button:
            self.button.destroy()

        self.button = SkillpageGuiButton.SkillpageGuiButton(
            self.callback, self.skillId, 0)
        self.button['geom_scale'] = 0.089999999999999997
        self.button.reparentTo(self)
        self.button.resetFrameSize()
        self.button.attachQuantity(self.amt)

    def destroy(self):
        DirectFrame.destroy(self)

    def callback(self, skillId):
        localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId,
                                               0)

    def updateQuantity(self, amt):
        self.amt = amt
        if self.button:
            self.button.attachQuantity(amt)

    def update(self, task=None):
        inv = localAvatar.getInventory()
        if not inv:
            return Task.cont

        greyOut = 0
        amt = inv.getStackQuantity(self.skillId)
        if amt <= 0:
            greyOut = 1

        if amt != self.amt:
            self.amt = amt
            self.button.attachQuantity(amt)

        range = localAvatar.cr.battleMgr.getModifiedRechargeTime(
            localAvatar, InventoryType.UseItem)
        value = localAvatar.skillDiary.getTimeSpentRecharging(
            InventoryType.UseItem)
        if not value:
            value = range

        self.skillRing.update(value, range)
        if value < range:
            greyOut = 3

        if self.greyOut != greyOut:
            self.greyOut = greyOut
            if greyOut == 2:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
            elif greyOut == 1:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
                self.skillRing.meterFaceHalf1.setColorScale(
                    0.40000000000000002, 0.40000000000000002,
                    0.40000000000000002, 1.0)
                self.skillRing.meterFaceHalf2.setColorScale(
                    0.40000000000000002, 0.40000000000000002,
                    0.40000000000000002, 1.0)
            elif greyOut == 3:
                self.button['geom_color'] = Vec4(0.5, 0.5, 0.5, 1.0)
            else:
                self.button['geom_color'] = Vec4(1, 1, 1, 1)
                self.skillRing.meterFaceHalf1.setColorScale(1, 1, 1, 1.0)
                self.skillRing.meterFaceHalf2.setColorScale(1, 1, 1, 1.0)

        return Task.cont
 def __init__(self, rep, weaponMode):
     self.rep = rep
     self.weaponMode = weaponMode
     localAvatar.cr.targetMgr.reticle.hide()
     if self.weaponMode in (WeaponGlobals.MELEE, WeaponGlobals.COMBAT, WeaponGlobals.THROWING):
         target = base.cr.targetMgr.takeAim(localAvatar)
         if target:
             localAvatar.guiMgr.combatTray.beginAimAssist(target)
         
     
     base.win.movePointer(0, base.win.getXSize() / 2, base.win.getYSize() / 2)
     localAvatar.guiMgr.setSeaChestAllowed(False)
     self.radial = { }
     self.rframe = { }
     self.ammoAmt = { }
     self.rstatus = { }
     self.rstatus[0] = 0
     self.rframe[0] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing.reparentTo(aspect2d)
     skillRing.setPos(0.01, 0, 0.01)
     if not self.SkillIcons:
         self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
         icons = loader.loadModel('models/gui/gui_icons_weapon')
         icons.reparentTo(self.SkillIcons)
     
     if self.rep == InventoryType.DollRep and localAvatar.hasStickyTargets():
         asset = getSkillIconName(self.rep, 1)
     else:
         asset = getSkillIconName(self.rep, 0)
     self.radial[0] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_scale = ImageScale(self.rep), image_pos = (0.059999999999999998, 0, 0.059999999999999998), pos = (-0.050000000000000003, 0, -0.050000000000000003), sortOrder = 10)
     self.radial[0].setTransparency(1)
     origMap = ActiveSkills(self.rep, 2)
     self.radialSkillMap = Freebooter.pruneFreebooterSkills(origMap)
     self.numberOfItems = len(self.radialSkillMap)
     for i in range(self.numberOfItems):
         (x, y) = InnerRingOffset(i + 1)
         self.rstatus[i + 1] = 0
         self.rframe[i + 1] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing.reparentTo(aspect2d)
         skillRing.setPos(0.01 + x, 0, 0.01 + y)
         asset = getSkillIconName(self.radialSkillMap[i], 0)
         self.radial[i + 1] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_pos = (0.059999999999999998, 0, 0.059999999999999998), image_scale = ImageScale(self.rep), sortOrder = 100, pos = (-0.050000000000000003 + x, 0, -0.050000000000000003 + y))
         self.radial[i + 1].setTransparency(1)
         if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE):
             inv = localAvatar.getInventory()
             skillId = self.radialSkillMap[i]
             maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId)
             if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId):
                 amtstr = '++'
             else:
                 ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                 ammoAmt = inv.getStackQuantity(ammoInvId)
                 ammoMax = inv.getStackLimit(ammoInvId)
                 amtstr = '%d' % ammoAmt
             self.ammoAmt[i + 1] = DirectLabel(parent = aspect2d, relief = None, text = amtstr, text_align = TextNode.ACenter, text_scale = 0.029999999999999999, text_fg = (0.69999999999999996, 1.0, 1.0, 1), text_font = PiratesGlobals.getPirateBoldOutlineFont(), pos = (x + 0.059999999999999998, 0, y + 0.040000000000000001), textMayChange = 1)
             continue
     
     self.mouseBasePosX = base.win.getXSize() / 2
     self.mouseBasePosY = base.win.getYSize() / 2
     self.radialHelp = DirectLabel(parent = aspect2d, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_fg = (0.94999999999999996, 1.0, 1.0, 1), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0), textMayChange = 1)
     self.radialHelp.hide()
     self.radial[0].show()
     self.rframe[0].show()
     self.hiLiteItem = 0
     taskMgr.add(self.radialMenuHeartBeat, 'radialMenuHeartBeat', priority = 40)
     messenger.send('openedSpecialMenu')
示例#9
0
    def __init__(self,
                 skillId,
                 callback,
                 quantity=0,
                 skillRank=0,
                 showQuantity=False,
                 showHelp=False,
                 showRing=False,
                 hotkey=None,
                 name='',
                 showIcon=True,
                 showLock=False,
                 rechargeSkillId=False,
                 isWeaponSkill=False,
                 assocAmmo=[]):
        DirectFrame.__init__(self, parent=NodePath(), relief=None)
        self.initialiseoptions(SkillButton)
        gui = loader.loadModel('models/gui/toplevel_gui')
        if not SkillButton.SkillIcons:
            print 'not SkillButton.SkillIcons:'
            SkillButton.SkillIcons = loader.loadModel(
                'models/textureCards/skillIcons')
            SkillButton.Image = (SkillButton.SkillIcons.find('**/base'),
                                 SkillButton.SkillIcons.find('**/base_down'),
                                 SkillButton.SkillIcons.find('**/base_over'))
            SkillButton.SkillRechargedSound = loadSfx(
                SoundGlobals.SFX_SKILL_RECHARGED)
            SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber')
            SkillButton.SpecialIcons = []
            for entry in SPECIAL_SKILL_ICONS:
                if not entry:
                    SkillButton.SpecialIcons.append(None)
                    continue
                specialImage = (SkillButton.SkillIcons.find('**/%s' % entry), )
                SkillButton.SpecialIcons.append(specialImage)

        model = loader.loadModel('models/effects/particleMaps')
        toggleIcon = model.find('**/particleGlow')
        toggleIcon.node().setAttrib(
            ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        self.toggleFrame = DirectFrame(relief=None,
                                       state=DGG.DISABLED,
                                       parent=self,
                                       image=toggleIcon,
                                       image_scale=0.34999999999999998,
                                       image_pos=(0.0, 0.0, -0.01))
        self.toggleFrame.hide()
        self.glowRing = None
        self.glowRing2 = None
        self.assocAmmo = assocAmmo
        self.skillId = skillId
        self.quantity = quantity
        self.showQuantity = showQuantity
        self.skillRank = skillRank
        self.skillRing = None
        self.callback = callback
        self.showUpgrade = False
        self.showHelp = showHelp
        self.showRing = showRing
        self.showIcon = showIcon
        self.showLock = showLock
        self.isWeaponSkill = isWeaponSkill
        self.lock = None
        self.name = name
        self.helpFrame = None
        self.quantityLabel = None
        self.skillButton = None
        self.hotkeyLabel = None
        self.hotkey = hotkey
        self.greyOut = 0
        self.tonicId = 0
        self.skillRingIval = None
        self.impulseIval = None
        self.quickImpulseIval = None
        self.isBreakAttackSkill = WeaponGlobals.getSkillTrack(
            self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX
        self.isDefenseSkill = WeaponGlobals.getSkillTrack(
            self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX
        self.rechargeFilled = 0
        self.defenseAuraEffect = None
        if self.isWeaponSkill:
            self.weaponBackground = DirectLabel(
                parent=self,
                state=DGG.DISABLED,
                image=SkillButton.SkillIcons.find('**/box_base'),
                image_scale=(0.22, 0, 0.22),
                image_pos=(0.0, 0.0, 0.0))
            self.weaponBackground.flattenLight()
            self.weaponBackground.setColor(0.20000000000000001,
                                           0.20000000000000001,
                                           0.20000000000000001,
                                           0.20000000000000001)
            self.weaponBackground.setTransparency(1)

        if showRing:
            if self.isBreakAttackSkill:
                color = Vec4(1, 0, 0, 1)
            elif self.isDefenseSkill:
                color = Vec4(0, 1, 1, 1)
            else:
                color = Vec4(1, 0.80000000000000004, 0.5, 1)
            self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0))
            gs = self.skillRing.meterFaceHalf2.node().getGeomState(0)
            self.skillRing.meterFaceHalf2.node().setGeomState(
                0, gs.removeAttrib(ColorAttrib.getClassType()))
            self.skillRing.reparentTo(self, 0)
            self.skillRing.setPos(0, 0, 0)

        self.updateSkillId(skillId)
        if showQuantity:
            self.updateQuantity(quantity)

        if hotkey:
            self.createHotkey(hotkey)

        if showLock:
            self.createLock()

        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag(
                skillId):
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                localAvatar, InventoryType.UseItem)
            self.tonicId = InventoryType.UseItem
        else:
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                localAvatar, self.skillId)
        if showRing:
            if not self.isBreakAttackSkill:
                self.createSkillRingIval()

            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    self.skillId)
            if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime:
                self.updateRechargeRing()
            elif not (self.isBreakAttackSkill):
                if (self.totalRechargeTime or timeSpentRecharging
                    ) and not (timeSpentRecharging > self.totalRechargeTime):
                    self.skillRingIval.start(startT=timeSpentRecharging)

            not (timeSpentRecharging > self.totalRechargeTime)
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.meterFaceHalf1.setColor(
                self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf2.setColor(
                self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf1.show()
            self.skillRing.meterFaceHalf2.show()

        if not self.isBreakAttackSkill:
            self.checkAmount()

        if self.isDefenseSkill:
            self.startRecharge()

        if self.isWeaponSkill:
            self.weaponLabel = DirectLabel(
                parent=self,
                relief=None,
                text=PLocalizer.WeaponAbility,
                text_font=PiratesGlobals.getPirateBoldOutlineFont(),
                text_align=TextNode.ACenter,
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                textMayChange=0,
                pos=(0.0, 0, -0.12),
                sortOrder=70,
                state=DGG.DISABLED)
            self.weaponLabel.flattenLight()
示例#10
0
class SkillButton(DirectFrame):
    notify = directNotify.newCategory('SkillButton')
    SkillIcons = None
    Image = None
    SkillRechargedSound = None
    SubLock = None

    def __init__(self,
                 skillId,
                 callback,
                 quantity=0,
                 skillRank=0,
                 showQuantity=False,
                 showHelp=False,
                 showRing=False,
                 hotkey=None,
                 name='',
                 showIcon=True,
                 showLock=False,
                 rechargeSkillId=False,
                 isWeaponSkill=False,
                 assocAmmo=[]):
        DirectFrame.__init__(self, parent=NodePath(), relief=None)
        self.initialiseoptions(SkillButton)
        gui = loader.loadModel('models/gui/toplevel_gui')
        if not SkillButton.SkillIcons:
            print 'not SkillButton.SkillIcons:'
            SkillButton.SkillIcons = loader.loadModel(
                'models/textureCards/skillIcons')
            SkillButton.Image = (SkillButton.SkillIcons.find('**/base'),
                                 SkillButton.SkillIcons.find('**/base_down'),
                                 SkillButton.SkillIcons.find('**/base_over'))
            SkillButton.SkillRechargedSound = loadSfx(
                SoundGlobals.SFX_SKILL_RECHARGED)
            SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber')
            SkillButton.SpecialIcons = []
            for entry in SPECIAL_SKILL_ICONS:
                if not entry:
                    SkillButton.SpecialIcons.append(None)
                    continue
                specialImage = (SkillButton.SkillIcons.find('**/%s' % entry), )
                SkillButton.SpecialIcons.append(specialImage)

        model = loader.loadModel('models/effects/particleMaps')
        toggleIcon = model.find('**/particleGlow')
        toggleIcon.node().setAttrib(
            ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        self.toggleFrame = DirectFrame(relief=None,
                                       state=DGG.DISABLED,
                                       parent=self,
                                       image=toggleIcon,
                                       image_scale=0.34999999999999998,
                                       image_pos=(0.0, 0.0, -0.01))
        self.toggleFrame.hide()
        self.glowRing = None
        self.glowRing2 = None
        self.assocAmmo = assocAmmo
        self.skillId = skillId
        self.quantity = quantity
        self.showQuantity = showQuantity
        self.skillRank = skillRank
        self.skillRing = None
        self.callback = callback
        self.showUpgrade = False
        self.showHelp = showHelp
        self.showRing = showRing
        self.showIcon = showIcon
        self.showLock = showLock
        self.isWeaponSkill = isWeaponSkill
        self.lock = None
        self.name = name
        self.helpFrame = None
        self.quantityLabel = None
        self.skillButton = None
        self.hotkeyLabel = None
        self.hotkey = hotkey
        self.greyOut = 0
        self.tonicId = 0
        self.skillRingIval = None
        self.impulseIval = None
        self.quickImpulseIval = None
        self.isBreakAttackSkill = WeaponGlobals.getSkillTrack(
            self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX
        self.isDefenseSkill = WeaponGlobals.getSkillTrack(
            self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX
        self.rechargeFilled = 0
        self.defenseAuraEffect = None
        if self.isWeaponSkill:
            self.weaponBackground = DirectLabel(
                parent=self,
                state=DGG.DISABLED,
                image=SkillButton.SkillIcons.find('**/box_base'),
                image_scale=(0.22, 0, 0.22),
                image_pos=(0.0, 0.0, 0.0))
            self.weaponBackground.flattenLight()
            self.weaponBackground.setColor(0.20000000000000001,
                                           0.20000000000000001,
                                           0.20000000000000001,
                                           0.20000000000000001)
            self.weaponBackground.setTransparency(1)

        if showRing:
            if self.isBreakAttackSkill:
                color = Vec4(1, 0, 0, 1)
            elif self.isDefenseSkill:
                color = Vec4(0, 1, 1, 1)
            else:
                color = Vec4(1, 0.80000000000000004, 0.5, 1)
            self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0))
            gs = self.skillRing.meterFaceHalf2.node().getGeomState(0)
            self.skillRing.meterFaceHalf2.node().setGeomState(
                0, gs.removeAttrib(ColorAttrib.getClassType()))
            self.skillRing.reparentTo(self, 0)
            self.skillRing.setPos(0, 0, 0)

        self.updateSkillId(skillId)
        if showQuantity:
            self.updateQuantity(quantity)

        if hotkey:
            self.createHotkey(hotkey)

        if showLock:
            self.createLock()

        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag(
                skillId):
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                localAvatar, InventoryType.UseItem)
            self.tonicId = InventoryType.UseItem
        else:
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                localAvatar, self.skillId)
        if showRing:
            if not self.isBreakAttackSkill:
                self.createSkillRingIval()

            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    self.skillId)
            if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime:
                self.updateRechargeRing()
            elif not (self.isBreakAttackSkill):
                if (self.totalRechargeTime or timeSpentRecharging
                    ) and not (timeSpentRecharging > self.totalRechargeTime):
                    self.skillRingIval.start(startT=timeSpentRecharging)

            not (timeSpentRecharging > self.totalRechargeTime)
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.meterFaceHalf1.setColor(
                self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf2.setColor(
                self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf1.show()
            self.skillRing.meterFaceHalf2.show()

        if not self.isBreakAttackSkill:
            self.checkAmount()

        if self.isDefenseSkill:
            self.startRecharge()

        if self.isWeaponSkill:
            self.weaponLabel = DirectLabel(
                parent=self,
                relief=None,
                text=PLocalizer.WeaponAbility,
                text_font=PiratesGlobals.getPirateBoldOutlineFont(),
                text_align=TextNode.ACenter,
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                textMayChange=0,
                pos=(0.0, 0, -0.12),
                sortOrder=70,
                state=DGG.DISABLED)
            self.weaponLabel.flattenLight()

    def loadGlowRing(self):
        self.glowRing = loader.loadModel('models/effects/battleEffects').find(
            '**/effectVoodooShockwave')
        self.glowRing.node().setAttrib(
            ColorBlendAttrib.make(ColorBlendAttrib.MAdd,
                                  ColorBlendAttrib.OIncomingAlpha,
                                  ColorBlendAttrib.OOne))
        self.glowRing.reparentTo(self)
        self.glowRing.setBin('transparent', 0)
        self.glowRing.setScale(0.20000000000000001)
        self.glowRing.hide()
        self.glowRing2 = loader.loadModel('models/effects/particleMaps').find(
            '**/particleGlow')
        self.glowRing2.node().setAttrib(
            ColorBlendAttrib.make(ColorBlendAttrib.MAdd,
                                  ColorBlendAttrib.OOneMinusIncomingAlpha,
                                  ColorBlendAttrib.OOne))
        self.glowRing2.reparentTo(self)
        self.glowRing2.setBin('transparent', 0)
        self.glowRing2.setScale(0.20000000000000001)
        self.glowRing2.setColor(0.80000000000000004, 1, 0.80000000000000004,
                                0.20000000000000001)
        self.glowRing2.reparentTo(self)
        self.glowRing2.hide()

    def checkAmount(self):
        if not (self.quantity) and self.showQuantity:
            if self.showRing and not self.skillRingIval.isPlaying():
                self.setGeomColor(0.5, 0.5, 0.5, 1.0)
                self.setRingColor(Vec4(0.5, 0.5, 0.5, 1.0))

        elif self.showRing and not self.skillRingIval.isPlaying():
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.setRingColor(self.skillRing.meterActiveColor)

    def toggleButton(self, state):
        if state == True:
            self.toggleFrame.show()
        elif state == False:
            self.toggleFrame.hide()

    def createSkillRingIval(self):
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.setScale(1.0)
            self.skillRing.clearColorScale()
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.checkAmount()
            self.skillRingIval = None

        if self.tonicId:
            timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                InventoryType.UseItem)
        else:
            timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                self.skillId)
        if self.isDefenseSkill:
            localAvatar.setDefenceEffect(self.skillId)

        if self.showRing:
            self.skillRingIval = Sequence(
                Func(localAvatar.setDefenceEffect, 0),
                Func(self.setGeomColor, 0.5, 0.5, 0.5, 1.0),
                Func(self.skillRing.meterFaceHalf1.setColor,
                     self.skillRing.meterActiveColor, 100),
                Func(self.skillRing.meterFaceHalf2.setColor,
                     self.skillRing.meterColor, 100),
                Func(self.skillRing.meterFaceHalf1.setR, 0),
                Func(self.skillRing.meterFaceHalf2.setR, 0),
                Func(self.skillRing.meterFaceHalf1.show),
                Func(self.skillRing.meterFaceHalf2.show),
                LerpFunc(self.skillRing.meterFaceHalf2.setR,
                         self.totalRechargeTime / 2, 0, -180),
                Func(self.skillRing.meterFaceHalf2.setColor,
                     self.skillRing.meterActiveColor, 100),
                Func(self.skillRing.meterFaceHalf2.setR, 0),
                LerpFunc(self.skillRing.meterFaceHalf1.setR,
                         self.totalRechargeTime / 2, 0, -180),
                Func(self.setGeomColor, 1.0, 1.0, 1.0, 1.0),
                Func(base.playSfx, SkillButton.SkillRechargedSound,
                     volume=0.5),
                Parallel(
                    LerpScaleInterval(self.skillRing, 0.10000000000000001,
                                      Vec3(1.2, 1.2, 1.2)),
                    LerpColorScaleInterval(self.skillRing,
                                           0.10000000000000001,
                                           Vec4(0.0, 0.75, 0.0, 1.0),
                                           Vec4(1.0, 1.0, 1.0, 1.0),
                                           blendType='easeInOut')),
                Func(localAvatar.setDefenceEffect, self.skillId),
                LerpScaleInterval(
                    self.skillRing, 0.20000000000000001,
                    Vec3(0.90000000000000002, 0.90000000000000002,
                         0.90000000000000002)),
                LerpScaleInterval(
                    self.skillRing, 0.029999999999999999,
                    Vec3(1.1000000000000001, 1.1000000000000001,
                         1.1000000000000001)),
                Parallel(
                    LerpScaleInterval(self.skillRing, 0.029999999999999999,
                                      Vec3(1.0, 1.0, 1.0)),
                    LerpColorScaleInterval(self.skillRing,
                                           1,
                                           Vec4(1.0, 1.0, 1.0, 1.0),
                                           blendType='easeInOut')),
                Func(self.skillRing.clearColorScale), Func(self.checkAmount))

    def updateSkillRingIval(self):
        if self.showRing:
            playing = self.skillRingIval.isPlaying()
            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
                    self.skillId)
            if timeSpentRecharging:
                skillRechargeProgress = timeSpentRecharging / self.totalRechargeTime

            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                localAvatar, self.skillId)
            if not self.totalRechargeTime:
                self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
                    localAvatar, InventoryType.UseItem)

            if timeSpentRecharging:
                timeSpentRecharging = skillRechargeProgress * self.totalRechargeTime
                localAvatar.skillDiary.modifyTimeSpentRecharging(
                    self.skillId, timeSpentRecharging)

            self.createSkillRingIval()
            if playing and timeSpentRecharging:
                self.skillRingIval.start(startT=timeSpentRecharging)

    def quickGlowImpulse(self):
        if not self.glowRing2:
            self.loadGlowRing()

        self.quickImpulseIval = Sequence(
            Func(self.glowRing2.show),
            LerpScaleInterval(
                self.glowRing2, 0.20000000000000001,
                Vec3(0.33000000000000002, 0.33000000000000002,
                     0.33000000000000002)),
            LerpScaleInterval(
                self.glowRing2, 0.25,
                Vec3(0.20000000000000001, 0.20000000000000001,
                     0.20000000000000001)), Func(self.glowRing2.hide))
        self.quickImpulseIval.start()

    def startPowerImpulse(self):
        if not self.glowRing:
            self.loadGlowRing()

        self.glowRing.show()
        self.impulseIval = Sequence(
            Parallel(
                LerpScaleInterval(
                    self.glowRing, 0.10000000000000001,
                    Vec3(0.20300000000000001, 0.20300000000000001,
                         0.20300000000000001)),
                LerpColorScaleInterval(self.glowRing,
                                       0.10000000000000001,
                                       Vec4(0.80000000000000004,
                                            0.80000000000000004,
                                            0.80000000000000004,
                                            0.80000000000000004),
                                       Vec4(1.0, 1.0, 1.0,
                                            0.80000000000000004),
                                       blendType='easeInOut')),
            LerpScaleInterval(self.glowRing, 0.14999999999999999,
                              Vec3(0.19, 0.19, 0.19)),
            LerpScaleInterval(
                self.glowRing, 0.050000000000000003,
                Vec3(0.20200000000000001, 0.20200000000000001,
                     0.20200000000000001)),
            Parallel(
                LerpScaleInterval(
                    self.glowRing, 0.029999999999999999,
                    Vec3(0.20000000000000001, 0.20000000000000001,
                         0.20000000000000001)),
                LerpColorScaleInterval(self.glowRing,
                                       0.40000000000000002,
                                       Vec4(1.0, 1.0, 1.0, 1.0),
                                       blendType='easeInOut')),
            Func(self.glowRing.clearColorScale))
        self.impulseIval.loop()

    def stopPowerImpulse(self):
        if self.glowRing:
            self.glowRing.hide()

        if self.impulseIval:
            self.impulseIval.finish()
            self.impulseIval = None

    def updateRechargeRing(self):
        timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(
            self.skillId)
        self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(
            localAvatar, self.skillId)
        if timeSpentRecharging >= self.totalRechargeTime and not (
                self.rechargeFilled):
            self.rechargeFilled = 1
            if self.skillRingIval:
                self.skillRingIval.pause()
                self.skillRingIval = None

            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.setScale(1.0)
            self.skillRing.clearColorScale()
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.skillRingIval = Sequence(
                Func(base.playSfx, SkillButton.SkillRechargedSound,
                     volume=0.5),
                Parallel(
                    LerpScaleInterval(self.skillRing, 0.10000000000000001,
                                      Vec3(1.2, 1.2, 1.2)),
                    LerpColorScaleInterval(self.skillRing,
                                           0.10000000000000001,
                                           Vec4(0.0, 0.75, 0.0, 1.0),
                                           Vec4(1.0, 1.0, 1.0, 1.0),
                                           blendType='easeInOut')),
                Func(localAvatar.setDefenceEffect, self.skillId),
                LerpScaleInterval(
                    self.skillRing, 0.20000000000000001,
                    Vec3(0.90000000000000002, 0.90000000000000002,
                         0.90000000000000002)),
                LerpScaleInterval(
                    self.skillRing, 0.029999999999999999,
                    Vec3(1.1000000000000001, 1.1000000000000001,
                         1.1000000000000001)),
                Parallel(
                    LerpScaleInterval(self.skillRing, 0.029999999999999999,
                                      Vec3(1.0, 1.0, 1.0)),
                    LerpColorScaleInterval(self.skillRing,
                                           1,
                                           Vec4(1.0, 1.0, 1.0, 1.0),
                                           blendType='easeInOut')),
                Func(self.skillRing.clearColorScale))
            self.skillRingIval.start()
        elif timeSpentRecharging < self.totalRechargeTime:
            self.rechargeFilled = 0
            self.setGeomColor(0.5, 0.5, 0.5, 1.0)
            self.skillRing.update(timeSpentRecharging, self.totalRechargeTime)

    def updateSkillId(self, skillId):
        self.skillId = skillId
        if self.skillButton:
            if self.quantityLabel:
                self.quantityLabel.detachNode()

            self.skillButton.destroy()

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

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

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

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

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

        if self.showRing:
            image = None
        else:
            image = SkillButton.Image
        self.skillButton = DirectButton(parent=self,
                                        relief=None,
                                        pos=(0, 0, 0),
                                        text=('', '', self.name),
                                        text_align=TextNode.ACenter,
                                        text_shadow=Vec4(0, 0, 0, 1),
                                        text_scale=0.040000000000000001,
                                        text_fg=Vec4(1, 1, 1, 1),
                                        text_pos=(0.0, 0.089999999999999997),
                                        image=image,
                                        image_scale=0.14999999999999999,
                                        image_color=image_color,
                                        geom=geom,
                                        geom_scale=geom_scale,
                                        geom_color=geomColor,
                                        command=self.callback,
                                        sortOrder=50,
                                        extraArgs=[skillId])
        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel.reparentTo(self.skillButton)

    def createHotkey(self, hotkey):
        self.hotkeyLabel = DirectLabel(
            parent=self,
            relief=None,
            text=hotkey,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            text_align=TextNode.ARight,
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            textMayChange=0,
            pos=(0.070000000000000007, 0, -0.059999999999999998),
            sortOrder=70,
            state=DGG.DISABLED)
        self.hotkeyLabel.flattenLight()

    def createLock(self):
        if self.lock:
            return None

        self.lock = DirectFrame(parent=self,
                                relief=None,
                                image=SkillButton.SubLock,
                                image_scale=0.14000000000000001,
                                image_pos=(0.050000000000000003, 0,
                                           -0.025000000000000001),
                                sortOrder=99)
        if self.showIcon:
            self.lock.setColorScale(0.90000000000000002, 0.90000000000000002,
                                    0.90000000000000002, 1)
            self.skillButton.setColorScale(0.40000000000000002,
                                           0.40000000000000002,
                                           0.40000000000000002, 1, 1)
        else:
            self.lock.setColorScale(0.59999999999999998, 0.59999999999999998,
                                    0.59999999999999998, 1, 2)
            self.skillButton.clearColorScale()
        if self.showHelp:
            self.lock.hide()

    def createHelpFrame(self, args=None):
        if self.helpFrame:
            return None

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

        baseRank = max(self.skillRank, 1)
        lvlDamageMod = WeaponGlobals.getLevelDamageModifier(
            localAvatar.getLevel())
        buff = WeaponGlobals.getSkillEffectFlag(self.skillId)
        dur = WeaponGlobals.getAttackDuration(self.skillId)
        effect = dur + dur * (baseRank - 1) / 4.0
        bonus = localAvatar.getSkillRankBonus(self.skillId)
        upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId)
        rank = localAvatar.getSkillRank(self.skillId)
        skillBoost = 0
        if self.skillId in ItemGlobals.getLinkedSkills(
                localAvatar.currentWeaponId):
            linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId)
            skillBoost = ItemGlobals.getWeaponBoosts(
                localAvatar.currentWeaponId, linkedSkillId)
            skillBoost += ItemGlobals.getWeaponBoosts(
                localAvatar.getCurrentCharm(), linkedSkillId)
        else:
            skillBoost = ItemGlobals.getWeaponBoosts(
                localAvatar.currentWeaponId, self.skillId)
            skillBoost += ItemGlobals.getWeaponBoosts(
                localAvatar.getCurrentCharm(), self.skillId)
        manaCost = 0
        if WeaponGlobals.getSkillTrack(
                self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX:
            manaCost = WeaponGlobals.getMojoCost(self.skillId)
            if manaCost < 0:
                amt = localAvatar.getSkillRankBonus(
                    InventoryType.StaffConservation)
                manaCost = min(manaCost - manaCost * amt, 1.0)

        damage = 0
        loDamage = 0
        mpDamage = 0
        mpLoDamage = 0
        if WeaponGlobals.getSkillTrack(
                self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX:
            damage = WeaponGlobals.getAttackSelfHP(self.skillId)
        elif WeaponGlobals.getSkillTrack(
                self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX:
            mod = (1.0 + bonus) * lvlDamageMod
            damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod)
            loDamage = damage / 2
            mpDamage = int(
                WeaponGlobals.getAttackTargetMojo(self.skillId) * mod)
            mpLoDamage = mpDamage / 2

        try:
            skillInfo = PLocalizer.SkillDescriptions.get(self.skillId)
            skillTitle = PLocalizer.makeHeadingString(
                PLocalizer.InventoryTypeNames.get(self.skillId), 2)
            skillType = PLocalizer.makeHeadingString(skillInfo[0], 1)
        except:
            self.notify.error('Error getting skill info for skillId %s' %
                              self.skillId)

        description = skillInfo[1]
        if damage < 0:
            description += ' ' + PLocalizer.DealsDamage
        elif damage > 0:
            if loDamage:
                loDamage = 0
                description += ' ' + PLocalizer.HealsDamageRange
            else:
                description += ' ' + PLocalizer.HealsDamage

        if mpDamage < 0:
            description += ' ' + PLocalizer.DealsMpDamage

        effectId = WeaponGlobals.getSkillEffectFlag(self.skillId)
        if effectId:
            description += ' ' + SkillEffectDescriptions.get(effectId)[0]

        if bonus:
            if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight:
                description += ' ' + PLocalizer.BroadsideDesc

            if self.skillId == InventoryType.CannonShoot:
                description += ' ' + PLocalizer.CannonShootDesc

            if self.skillId == InventoryType.DollAttune:
                description += ' ' + PLocalizer.MultiAttuneDesc

        if WeaponGlobals.getSkillInterrupt(self.skillId):
            description += ' ' + PLocalizer.InterruptDesc

        if WeaponGlobals.getSkillUnattune(self.skillId):
            description += ' ' + PLocalizer.UnattuneDesc

        upgradeInfo = ''
        if self.showUpgrade and rank < 5:
            if rank > 0:
                upgradeInfo = skillInfo[2]
                if upgradeInfo == '':
                    if damage < 0:
                        upgradeInfo += PLocalizer.UpgradesDamage
                    elif damage > 0:
                        upgradeInfo += PLocalizer.UpgradesHealing

                    if mpDamage < 0:
                        upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage

                    if effectId:
                        entry = SkillEffectDescriptions.get(effectId)
                        if len(entry) > 1:
                            if not damage:
                                upgradeInfo += PLocalizer.UpgradesDuration
                            else:
                                upgradeInfo += ' ' + PLocalizer.And
                            upgradeInfo += ' ' + entry[1]

                    upgradeInfo += '!'

            elif len(upgradeInfo) >= 4:
                upgradeInfo = skillInfo[3]
            else:
                upgradeInfo = PLocalizer.ClickToLearn
        elif not self.showIcon:
            unlockLevel = RepChart.getSkillUnlockLevel(self.skillId)
            if unlockLevel > 0:
                upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel

        if self.skillId in SkillComboReq and SkillComboReq[
                self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2:
            color = 'red'
            if rank == 0:
                color = 'red'
                upgradeInfo = ''

            description += '\n' + color + SkillComboReq[self.skillId] + '.'

        skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo
        stats = []
        if manaCost:
            stats.append(abs(manaCost))

        if damage and loDamage:
            stats.append(abs(loDamage))
            stats.append(abs(damage))
        elif damage:
            stats.append(abs(damage))

        if mpDamage:
            stats.append(abs(mpLoDamage))
            stats.append(abs(mpDamage))

        if buff == WeaponGlobals.C_CURSE:
            stats.append(WeaponGlobals.CURSED_DAM_AMP * 100)

        if buff == WeaponGlobals.C_WEAKEN:
            stats.append(WeaponGlobals.WEAKEN_PENALTY * 100)

        if effect > 0:
            stats.append(effect)

        if skillInfo[4]:
            if bonus == 0 and upgradeAmt > 0:
                if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight:
                    pass
                if not (self.skillId == InventoryType.CannonShoot):
                    bonus = upgradeAmt

            if upgradeAmt < 1.0 and upgradeAmt > 0:
                bonus *= 100

            if self.skillId == InventoryType.SailTreasureSense:
                bonus /= 2.0
            elif self.skillId == InventoryType.CutlassParry:
                bonus += WeaponGlobals.getSubtypeParryBonus(
                    localAvatar.currentWeaponId)

            if bonus:
                stats.append(abs(bonus))

        if self.skillId == InventoryType.DollAttune:
            stats.append(rank)

        if self.skillRank:
            rankText = DirectFrame(parent=self,
                                   relief=None,
                                   text=PLocalizer.makeHeadingString(
                                       PLocalizer.Rank + ' %s' %
                                       (self.skillRank + skillBoost), 2),
                                   text_align=TextNode.ARight,
                                   text_scale=PiratesGuiGlobals.TextScaleSmall,
                                   text_fg=PiratesGuiGlobals.TextFG2,
                                   text_wordwrap=15,
                                   text_shadow=(0, 0, 0, 1),
                                   pos=(0.45000000000000001, 0, 0),
                                   textMayChange=1,
                                   sortOrder=92,
                                   state=DGG.DISABLED)

        stats = [stat + 0.01 for stat in stats]

        try:
            pass
        except TypeError:
            self.notify.error('Error formatting skillDesc(%s): %s' %
                              (self.skillId, stats))

        helpText = DirectFrame(parent=self,
                               relief=None,
                               text=skillDesc % stats,
                               text_align=TextNode.ALeft,
                               text_scale=PiratesGuiGlobals.TextScaleSmall,
                               text_fg=PiratesGuiGlobals.TextFG2,
                               text_wordwrap=17,
                               textMayChange=1,
                               state=DGG.DISABLED,
                               sortOrder=91)
        height = -(helpText.getHeight() + 0.01)
        if self.lock:
            height = height - 0.040000000000000001

        width = 0.55000000000000004
        self.helpFrame = BorderFrame(parent=self,
                                     state=DGG.DISABLED,
                                     frameSize=(-0.040000000000000001, width,
                                                height, 0.050000000000000003),
                                     pos=(0, 0, -0.12),
                                     sortOrder=90)
        self.helpFrame.setBin('gui-popup', 0)
        helpText.reparentTo(self.helpFrame)
        if self.skillRank:
            rankText.reparentTo(self.helpFrame)

        if self.lock:
            self.lockedFrame = DirectFrame(
                parent=self.helpFrame,
                relief=None,
                pos=(0.087999999999999995, 0, height + 0.029999999999999999),
                image=SkillButton.SubLock,
                image_scale=0.13,
                image_pos=(-0.055, 0, 0.012999999999999999),
                text=PLocalizer.VR_AuthAccess,
                text_scale=PiratesGuiGlobals.TextScaleSmall,
                text_align=TextNode.ALeft,
                text_fg=PiratesGuiGlobals.TextFG13)
            self.notify.debug('locked!')

        pos = self.helpFrame.getPos(aspect2d)
        x = min(pos[0], base.a2dRight - width)
        z = max(pos[2], base.a2dBottom - height)
        self.helpFrame.setPos(aspect2d, x, 0, z)

    def showDetails(self, event):
        if self.showHelp:
            self.createHelpFrame()

        if self.showRing:
            self.skillRing.rollover(True)

    def hideDetails(self, event):
        if self.helpFrame:
            self.helpFrame.destroy()
            self.helpFrame = None

        if self.showRing:
            self.skillRing.rollover(False)

    def updateQuantity(self, quantity):
        self.quantity = quantity
        if not self.showQuantity:
            return None

        if quantity == WeaponGlobals.INF_QUANT:
            text = ''
        elif self.assocAmmo:
            assocQuantity = 0
            inv = localAvatar.getInventory()
            if inv:
                for ammoId in self.assocAmmo:
                    assocQuantity += inv.getItemQuantity(
                        self.getAmmoCat(), ammoId)

            if quantity != assocQuantity:
                text = '%s' % assocQuantity
            else:
                text = 'x%s' % quantity
        else:
            text = 'x%s' % quantity
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel['text'] = text
        else:
            self.quantityLabel = DirectLabel(
                parent=NodePath(),
                relief=None,
                state=DGG.DISABLED,
                text=text,
                frameColor=(0, 0, 0, 1),
                frameSize=(-0.01, 0.02, -0.01, 0.025000000000000001),
                text_scale=PiratesGuiGlobals.TextScaleLarge,
                text_align=TextNode.ACenter,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_wordwrap=11,
                pos=(0.029999999999999999, 0.0, 0.029999999999999999),
                text_font=PiratesGlobals.getPirateBoldOutlineFont(),
                sortOrder=60)
            self.quantityLabel.flattenLight()
            self.quantityLabel.reparentTo(self)
            if self.skillButton and not self.skillButton.isEmpty():
                self.quantityLabel.reparentTo(self.skillButton)

    def getAmmoCat(self):
        pass

    def startRecharge(self):
        if not self.showRing:
            return None

        if self.isBreakAttackSkill:
            self.setGeomColor(0.5, 0.5, 0.5, 1.0)
            self.updateRechargeRing()
            return None

        if self.skillRingIval.isPlaying():
            self.createSkillRingIval()

        self.skillRingIval.start()

    def stopRecharge(self):
        if self.showRing:
            if self.isBreakAttackSkill:
                self.setGeomColor(0.5, 0.5, 0.5, 1.0)
                self.updateRechargeRing()
                return None

            if self.skillRingIval.isPlaying():
                self.skillRingIval.pause()

    def setGeomColor(self, r, g, b, a):
        self.skillButton['geom_color'] = Vec4(r, g, b, a)

    def setRingColor(self, color):
        self.skillRing.meterFaceHalf1.setColor(color[0], color[1], color[2],
                                               color[3], 100)
        self.skillRing.meterFaceHalf2.setColor(color[0], color[1], color[2],
                                               color[3], 100)

    def setShowUpgrade(self, show):
        if self.showUpgrade != show:
            self.showUpgrade = show
            if self.helpFrame:
                self.helpFrame.destroy()
                self.helpFrame = None
                self.showDetails(None)

    def setShowIcon(self, show):
        if self.showIcon != show:
            self.showIcon = show
            self.updateSkillId(self.skillId)
            if self.helpFrame:
                self.helpFrame.destroy()
                self.helpFrame = None

    def setShowLock(self, show):
        if self.showLock != show:
            self.showLock = show
            if show:
                self.createLock()
            elif self.lock:
                self.lock.destroy()
                self.lock = None
                self.skillButton.clearColorScale()

    def destroy(self):
        self.callback = None
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRingIval = None

        if self.quantityLabel:
            self.quantityLabel.destroy()
            self.quantityLabel = None

        if self.impulseIval:
            self.impulseIval.pause()
            self.impulseIval = None

        if self.quickImpulseIval:
            self.quickImpulseIval.pause()
            self.quickImpulseIval = None

        self.ignoreAll()
        DirectFrame.destroy(self)
示例#11
0
class CrewBuffDisplay(DirectFrame):
    
    def __init__(self, parent, skillIcon = None, duration = 10, buffName = '', buffDesc = '', **kw):
        DirectFrame.__init__(self, parent, **None)
        self.dummyFrame = None
        self.skillRingFrame = None
        self.skillIconFrame = None
        self.buffNameFrame = None
        self.buffDescFrame = None
        self.buffTitle = None
        self.skillIcon = skillIcon
        self.duration = duration
        self.currTime = duration
        self.buffName = buffName
        self.buffDesc = buffDesc
        self.skillRingIval = None
        self.runInIval = None
        self.loadGui()

    
    def destroy(self):
        self.ignoreAll()
        if self.skillRingFrame:
            self.skillRingFrame.destroy()
            self.skillRingFrame = None
        
        if self.skillIconFrame:
            self.skillIconFrame.destroy()
            self.skillIconFrame = None
        
        if self.buffNameFrame:
            self.buffNameFrame.destroy()
            self.buffNameFrame = None
        
        if self.buffDescFrame:
            self.buffDescFrame.destroy()
            self.buffDescFrame = None
        
        if self.buffTitle:
            self.buffTitle.destroy()
            self.buffTitle = None
        
        if self.dummyFrame:
            self.dummyFrame.destroy()
            self.dummyFrame = None
        
        DirectFrame.destroy(self)

    
    def loadGui(self):
        self.dummyFrame = DirectFrame(parent = self, relief = None, pos = (-0.42999999999999999, 0, 1.3799999999999999), sortOrder = -1000)
        self.skillRingFrame = SkillRing(color = Vec4(1, 1, 0, 1))
        self.skillRingFrame.reparentTo(self.dummyFrame)
        self.skillRingFrame.setPos(-0.089999999999999997, 0, -0.029999999999999999)
        self.skillIconFrame = DirectFrame(parent = self.skillRingFrame, pos = (0, 0, 0), relief = None, image = self.skillIcon, image_scale = (0.14000000000000001, 1, 0.14000000000000001))
        self.buffTitle = DirectFrame(parent = self.dummyFrame, relief = None, pos = (-0.16, 0, 0.080000000000000002), text = PLocalizer.CrewBuffCaptainOrder, text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG13, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
        self.buffNameFrame = DirectFrame(parent = self.dummyFrame, relief = None, pos = (0.0, 0, 0.0), text = self.buffName, text_align = TextNode.ALeft, text_scale = 0.047, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
        self.buffDescFrame = DirectFrame(parent = self.dummyFrame, relief = None, pos = (0.0, 0, -0.044999999999999998), text = self.buffDesc, text_align = TextNode.ALeft, text_scale = 0.036999999999999998, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())

    
    def createSkillRingIval(self):
        self.skillRingIval = Sequence(Func(self.skillRingFrame.meterFaceHalf1.setColor, self.skillRingFrame.meterActiveColor, 100), Func(self.skillRingFrame.meterFaceHalf2.setColor, self.skillRingFrame.meterActiveColor, 100), Func(self.skillRingFrame.meterFaceHalf1.setR, -180), Func(self.skillRingFrame.meterFaceHalf2.setR, 0), Func(self.skillRingFrame.meterFaceHalf1.show), Func(self.skillRingFrame.meterFaceHalf2.show), LerpFunc(self.skillRingFrame.meterFaceHalf2.setR, self.duration / 2, 0, 180), Func(self.skillRingFrame.meterFaceHalf2.setColor, Vec4(0, 0, 0, 1), 100), Func(self.skillRingFrame.meterFaceHalf2.setR, 0), LerpFunc(self.skillRingFrame.meterFaceHalf1.setR, self.duration / 2, -180, 0), Func(self.hide))

    
    def play(self):
        if not self.runInIval:
            self.runInIval = self.dummyFrame.posInterval(0.40000000000000002, Vec3(-0.42999999999999999, 0, 1.3799999999999999), startPos = Vec3(0.0, 0, 1.3799999999999999))
        
        self.runInIval.start()
        if not self.skillRingIval:
            self.createSkillRingIval()
        
        if self.skillRingIval:
            self.skillRingIval.start()
        

    
    def stop(self):
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRingIval = None
        
        if self.runInIval:
            self.runInIval.pause()
            self.runInIval = None
示例#12
0
 def __init__(self, rep, weaponMode):
     self.rep = rep
     self.weaponMode = weaponMode
     localAvatar.cr.targetMgr.reticle.hide()
     if self.weaponMode in (WeaponGlobals.MELEE, WeaponGlobals.COMBAT, WeaponGlobals.THROWING):
         target = base.cr.targetMgr.takeAim(localAvatar)
         if target:
             localAvatar.guiMgr.combatTray.beginAimAssist(target)
         
     
     base.win.movePointer(0, base.win.getXSize() / 2, base.win.getYSize() / 2)
     localAvatar.guiMgr.setSeaChestAllowed(False)
     self.radial = { }
     self.rframe = { }
     self.ammoAmt = { }
     self.rstatus = { }
     self.rstatus[0] = 0
     self.rframe[0] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
     skillRing.reparentTo(aspect2d)
     skillRing.setPos(0.01, 0, 0.01)
     if not self.SkillIcons:
         self.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
         icons = loader.loadModel('models/gui/gui_icons_weapon')
         icons.reparentTo(self.SkillIcons)
     
     if self.rep == InventoryType.DollRep and localAvatar.hasStickyTargets():
         asset = getSkillIconName(self.rep, 1)
     else:
         asset = getSkillIconName(self.rep, 0)
     self.radial[0] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_scale = ImageScale(self.rep), image_pos = (0.059999999999999998, 0, 0.059999999999999998), pos = (-0.050000000000000003, 0, -0.050000000000000003), sortOrder = 10)
     self.radial[0].setTransparency(1)
     origMap = ActiveSkills(self.rep, 2)
     self.radialSkillMap = Freebooter.pruneFreebooterSkills(origMap)
     self.numberOfItems = len(self.radialSkillMap)
     for i in range(self.numberOfItems):
         (x, y) = InnerRingOffset(i + 1)
         self.rstatus[i + 1] = 0
         self.rframe[i + 1] = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing = SkillRing(Vec4(1, 0.80000000000000004, 0.5, 1), Vec4(0, 0, 0, 1.0))
         skillRing.reparentTo(aspect2d)
         skillRing.setPos(0.01 + x, 0, 0.01 + y)
         asset = getSkillIconName(self.radialSkillMap[i], 0)
         self.radial[i + 1] = DirectFrame(parent = aspect2d, relief = None, image = self.SkillIcons.find('**/%s' % asset), image_pos = (0.059999999999999998, 0, 0.059999999999999998), image_scale = ImageScale(self.rep), sortOrder = 100, pos = (-0.050000000000000003 + x, 0, -0.050000000000000003 + y))
         self.radial[i + 1].setTransparency(1)
         if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE):
             inv = localAvatar.getInventory()
             skillId = self.radialSkillMap[i]
             maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId)
             if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId):
                 amtstr = '++'
             else:
                 ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                 ammoAmt = inv.getStackQuantity(ammoInvId)
                 ammoMax = inv.getStackLimit(ammoInvId)
                 amtstr = '%d' % ammoAmt
             self.ammoAmt[i + 1] = DirectLabel(parent = aspect2d, relief = None, text = amtstr, text_align = TextNode.ACenter, text_scale = 0.029999999999999999, text_fg = (0.69999999999999996, 1.0, 1.0, 1), text_font = PiratesGlobals.getPirateBoldOutlineFont(), pos = (x + 0.059999999999999998, 0, y + 0.040000000000000001), textMayChange = 1)
             continue
     
     self.mouseBasePosX = base.win.getXSize() / 2
     self.mouseBasePosY = base.win.getYSize() / 2
     self.radialHelp = DirectLabel(parent = aspect2d, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_fg = (0.94999999999999996, 1.0, 1.0, 1), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0), textMayChange = 1)
     self.radialHelp.hide()
     self.radial[0].show()
     self.rframe[0].show()
     self.hiLiteItem = 0
     taskMgr.add(self.radialMenuHeartBeat, 'radialMenuHeartBeat', priority = 40)
     messenger.send('openedSpecialMenu')
    def __init__(self, skillId, callback, quantity = 0, skillRank = 0, showQuantity = False, showHelp = False, showRing = False, hotkey = None, name = '', showIcon = True, showLock = False, rechargeSkillId = False, isWeaponSkill = False, assocAmmo = []):
        DirectFrame.__init__(self, parent = NodePath(), relief = None)
        self.initialiseoptions(SkillButton)
        gui = loader.loadModel('models/gui/toplevel_gui')
        if not SkillButton.SkillIcons:
            print 'not SkillButton.SkillIcons:'
            SkillButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
            SkillButton.Image = (SkillButton.SkillIcons.find('**/base'), SkillButton.SkillIcons.find('**/base_down'), SkillButton.SkillIcons.find('**/base_over'))
            SkillButton.SkillRechargedSound = loadSfx(SoundGlobals.SFX_SKILL_RECHARGED)
            SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber')
            SkillButton.SpecialIcons = []
            for entry in SPECIAL_SKILL_ICONS:
                if not entry:
                    SkillButton.SpecialIcons.append(None)
                    continue
                specialImage = (SkillButton.SkillIcons.find('**/%s' % entry),)
                SkillButton.SpecialIcons.append(specialImage)


        model = loader.loadModel('models/effects/particleMaps')
        toggleIcon = model.find('**/particleGlow')
        toggleIcon.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        self.toggleFrame = DirectFrame(relief = None, state = DGG.DISABLED, parent = self, image = toggleIcon, image_scale = 0.34999999999999998, image_pos = (0.0, 0.0, -0.01))
        self.toggleFrame.hide()
        self.glowRing = None
        self.glowRing2 = None
        self.assocAmmo = assocAmmo
        self.skillId = skillId
        self.quantity = quantity
        self.showQuantity = showQuantity
        self.skillRank = skillRank
        self.skillRing = None
        self.callback = callback
        self.showUpgrade = False
        self.showHelp = showHelp
        self.showRing = showRing
        self.showIcon = showIcon
        self.showLock = showLock
        self.isWeaponSkill = isWeaponSkill
        self.lock = None
        self.name = name
        self.helpFrame = None
        self.quantityLabel = None
        self.skillButton = None
        self.hotkeyLabel = None
        self.hotkey = hotkey
        self.greyOut = 0
        self.tonicId = 0
        self.skillRingIval = None
        self.impulseIval = None
        self.quickImpulseIval = None
        self.isBreakAttackSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX
        self.isDefenseSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX
        self.rechargeFilled = 0
        self.defenseAuraEffect = None
        if self.isWeaponSkill:
            self.weaponBackground = DirectLabel(parent = self, state = DGG.DISABLED, image = SkillButton.SkillIcons.find('**/box_base'), image_scale = (0.22, 0, 0.22), image_pos = (0.0, 0.0, 0.0))
            self.weaponBackground.flattenLight()
            self.weaponBackground.setColor(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.20000000000000001)
            self.weaponBackground.setTransparency(1)

        if showRing:
            if self.isBreakAttackSkill:
                color = Vec4(1, 0, 0, 1)
            elif self.isDefenseSkill:
                color = Vec4(0, 1, 1, 1)
            else:
                color = Vec4(1, 0.80000000000000004, 0.5, 1)
            self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0))
            gs = self.skillRing.meterFaceHalf2.node().getGeomState(0)
            self.skillRing.meterFaceHalf2.node().setGeomState(0, gs.removeAttrib(ColorAttrib.getClassType()))
            self.skillRing.reparentTo(self, 0)
            self.skillRing.setPos(0, 0, 0)

        self.updateSkillId(skillId)
        if showQuantity:
            self.updateQuantity(quantity)

        if hotkey:
            self.createHotkey(hotkey)

        if showLock:
            self.createLock()

        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag(skillId):
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem)
            self.tonicId = InventoryType.UseItem
        else:
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, self.skillId)
        if showRing:
            if not self.isBreakAttackSkill:
                self.createSkillRingIval()

            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId)
            if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime:
                self.updateRechargeRing()
            elif not (self.isBreakAttackSkill):
                if (self.totalRechargeTime or timeSpentRecharging) and not (timeSpentRecharging > self.totalRechargeTime):
                    self.skillRingIval.start(startT = timeSpentRecharging)

            not (timeSpentRecharging > self.totalRechargeTime)
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.meterFaceHalf1.setColor(self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf2.setColor(self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf1.show()
            self.skillRing.meterFaceHalf2.show()

        if not self.isBreakAttackSkill:
            self.checkAmount()

        if self.isDefenseSkill:
            self.startRecharge()

        if self.isWeaponSkill:
            self.weaponLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.WeaponAbility, text_font = PiratesGlobals.getPirateBoldOutlineFont(), text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, pos = (0.0, 0, -0.12), sortOrder = 70, state = DGG.DISABLED)
            self.weaponLabel.flattenLight()
class SkillButton(DirectFrame):
    notify = directNotify.newCategory('SkillButton')
    SkillIcons = None
    Image = None
    SkillRechargedSound = None
    SubLock = None

    def __init__(self, skillId, callback, quantity = 0, skillRank = 0, showQuantity = False, showHelp = False, showRing = False, hotkey = None, name = '', showIcon = True, showLock = False, rechargeSkillId = False, isWeaponSkill = False, assocAmmo = []):
        DirectFrame.__init__(self, parent = NodePath(), relief = None)
        self.initialiseoptions(SkillButton)
        gui = loader.loadModel('models/gui/toplevel_gui')
        if not SkillButton.SkillIcons:
            print 'not SkillButton.SkillIcons:'
            SkillButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons')
            SkillButton.Image = (SkillButton.SkillIcons.find('**/base'), SkillButton.SkillIcons.find('**/base_down'), SkillButton.SkillIcons.find('**/base_over'))
            SkillButton.SkillRechargedSound = loadSfx(SoundGlobals.SFX_SKILL_RECHARGED)
            SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber')
            SkillButton.SpecialIcons = []
            for entry in SPECIAL_SKILL_ICONS:
                if not entry:
                    SkillButton.SpecialIcons.append(None)
                    continue
                specialImage = (SkillButton.SkillIcons.find('**/%s' % entry),)
                SkillButton.SpecialIcons.append(specialImage)


        model = loader.loadModel('models/effects/particleMaps')
        toggleIcon = model.find('**/particleGlow')
        toggleIcon.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
        self.toggleFrame = DirectFrame(relief = None, state = DGG.DISABLED, parent = self, image = toggleIcon, image_scale = 0.34999999999999998, image_pos = (0.0, 0.0, -0.01))
        self.toggleFrame.hide()
        self.glowRing = None
        self.glowRing2 = None
        self.assocAmmo = assocAmmo
        self.skillId = skillId
        self.quantity = quantity
        self.showQuantity = showQuantity
        self.skillRank = skillRank
        self.skillRing = None
        self.callback = callback
        self.showUpgrade = False
        self.showHelp = showHelp
        self.showRing = showRing
        self.showIcon = showIcon
        self.showLock = showLock
        self.isWeaponSkill = isWeaponSkill
        self.lock = None
        self.name = name
        self.helpFrame = None
        self.quantityLabel = None
        self.skillButton = None
        self.hotkeyLabel = None
        self.hotkey = hotkey
        self.greyOut = 0
        self.tonicId = 0
        self.skillRingIval = None
        self.impulseIval = None
        self.quickImpulseIval = None
        self.isBreakAttackSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX
        self.isDefenseSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX
        self.rechargeFilled = 0
        self.defenseAuraEffect = None
        if self.isWeaponSkill:
            self.weaponBackground = DirectLabel(parent = self, state = DGG.DISABLED, image = SkillButton.SkillIcons.find('**/box_base'), image_scale = (0.22, 0, 0.22), image_pos = (0.0, 0.0, 0.0))
            self.weaponBackground.flattenLight()
            self.weaponBackground.setColor(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.20000000000000001)
            self.weaponBackground.setTransparency(1)

        if showRing:
            if self.isBreakAttackSkill:
                color = Vec4(1, 0, 0, 1)
            elif self.isDefenseSkill:
                color = Vec4(0, 1, 1, 1)
            else:
                color = Vec4(1, 0.80000000000000004, 0.5, 1)
            self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0))
            gs = self.skillRing.meterFaceHalf2.node().getGeomState(0)
            self.skillRing.meterFaceHalf2.node().setGeomState(0, gs.removeAttrib(ColorAttrib.getClassType()))
            self.skillRing.reparentTo(self, 0)
            self.skillRing.setPos(0, 0, 0)

        self.updateSkillId(skillId)
        if showQuantity:
            self.updateQuantity(quantity)

        if hotkey:
            self.createHotkey(hotkey)

        if showLock:
            self.createLock()

        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag(skillId):
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem)
            self.tonicId = InventoryType.UseItem
        else:
            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, self.skillId)
        if showRing:
            if not self.isBreakAttackSkill:
                self.createSkillRingIval()

            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId)
            if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime:
                self.updateRechargeRing()
            elif not (self.isBreakAttackSkill):
                if (self.totalRechargeTime or timeSpentRecharging) and not (timeSpentRecharging > self.totalRechargeTime):
                    self.skillRingIval.start(startT = timeSpentRecharging)

            not (timeSpentRecharging > self.totalRechargeTime)
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.meterFaceHalf1.setColor(self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf2.setColor(self.skillRing.meterActiveColor, 100)
            self.skillRing.meterFaceHalf1.show()
            self.skillRing.meterFaceHalf2.show()

        if not self.isBreakAttackSkill:
            self.checkAmount()

        if self.isDefenseSkill:
            self.startRecharge()

        if self.isWeaponSkill:
            self.weaponLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.WeaponAbility, text_font = PiratesGlobals.getPirateBoldOutlineFont(), text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, pos = (0.0, 0, -0.12), sortOrder = 70, state = DGG.DISABLED)
            self.weaponLabel.flattenLight()



    def loadGlowRing(self):
        self.glowRing = loader.loadModel('models/effects/battleEffects').find('**/effectVoodooShockwave')
        self.glowRing.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne))
        self.glowRing.reparentTo(self)
        self.glowRing.setBin('transparent', 0)
        self.glowRing.setScale(0.20000000000000001)
        self.glowRing.hide()
        self.glowRing2 = loader.loadModel('models/effects/particleMaps').find('**/particleGlow')
        self.glowRing2.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OOneMinusIncomingAlpha, ColorBlendAttrib.OOne))
        self.glowRing2.reparentTo(self)
        self.glowRing2.setBin('transparent', 0)
        self.glowRing2.setScale(0.20000000000000001)
        self.glowRing2.setColor(0.80000000000000004, 1, 0.80000000000000004, 0.20000000000000001)
        self.glowRing2.reparentTo(self)
        self.glowRing2.hide()


    def checkAmount(self):
        if not (self.quantity) and self.showQuantity:
            if self.showRing and not self.skillRingIval.isPlaying():
                self.setGeomColor(0.5, 0.5, 0.5, 1.0)
                self.setRingColor(Vec4(0.5, 0.5, 0.5, 1.0))

        elif self.showRing and not self.skillRingIval.isPlaying():
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.setRingColor(self.skillRing.meterActiveColor)



    def toggleButton(self, state):
        if state == True:
            self.toggleFrame.show()
        elif state == False:
            self.toggleFrame.hide()



    def createSkillRingIval(self):
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.setScale(1.0)
            self.skillRing.clearColorScale()
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.checkAmount()
            self.skillRingIval = None

        if self.tonicId:
            timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem)
        else:
            timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId)
        if self.isDefenseSkill:
            localAvatar.setDefenceEffect(self.skillId)

        if self.showRing:
            self.skillRingIval = Sequence(Func(localAvatar.setDefenceEffect, 0), Func(self.setGeomColor, 0.5, 0.5, 0.5, 1.0), Func(self.skillRing.meterFaceHalf1.setColor, self.skillRing.meterActiveColor, 100), Func(self.skillRing.meterFaceHalf2.setColor, self.skillRing.meterColor, 100), Func(self.skillRing.meterFaceHalf1.setR, 0), Func(self.skillRing.meterFaceHalf2.setR, 0), Func(self.skillRing.meterFaceHalf1.show), Func(self.skillRing.meterFaceHalf2.show), LerpFunc(self.skillRing.meterFaceHalf2.setR, self.totalRechargeTime / 2, 0, -180), Func(self.skillRing.meterFaceHalf2.setColor, self.skillRing.meterActiveColor, 100), Func(self.skillRing.meterFaceHalf2.setR, 0), LerpFunc(self.skillRing.meterFaceHalf1.setR, self.totalRechargeTime / 2, 0, -180), Func(self.setGeomColor, 1.0, 1.0, 1.0, 1.0), Func(base.playSfx, SkillButton.SkillRechargedSound, volume = 0.5), Parallel(LerpScaleInterval(self.skillRing, 0.10000000000000001, Vec3(1.2, 1.2, 1.2)), LerpColorScaleInterval(self.skillRing, 0.10000000000000001, Vec4(0.0, 0.75, 0.0, 1.0), Vec4(1.0, 1.0, 1.0, 1.0), blendType = 'easeInOut')), Func(localAvatar.setDefenceEffect, self.skillId), LerpScaleInterval(self.skillRing, 0.20000000000000001, Vec3(0.90000000000000002, 0.90000000000000002, 0.90000000000000002)), LerpScaleInterval(self.skillRing, 0.029999999999999999, Vec3(1.1000000000000001, 1.1000000000000001, 1.1000000000000001)), Parallel(LerpScaleInterval(self.skillRing, 0.029999999999999999, Vec3(1.0, 1.0, 1.0)), LerpColorScaleInterval(self.skillRing, 1, Vec4(1.0, 1.0, 1.0, 1.0), blendType = 'easeInOut')), Func(self.skillRing.clearColorScale), Func(self.checkAmount))



    def updateSkillRingIval(self):
        if self.showRing:
            playing = self.skillRingIval.isPlaying()
            if self.tonicId:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem)
            else:
                timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId)
            if timeSpentRecharging:
                skillRechargeProgress = timeSpentRecharging / self.totalRechargeTime

            self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, self.skillId)
            if not self.totalRechargeTime:
                self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem)

            if timeSpentRecharging:
                timeSpentRecharging = skillRechargeProgress * self.totalRechargeTime
                localAvatar.skillDiary.modifyTimeSpentRecharging(self.skillId, timeSpentRecharging)

            self.createSkillRingIval()
            if playing and timeSpentRecharging:
                self.skillRingIval.start(startT = timeSpentRecharging)




    def quickGlowImpulse(self):
        if not self.glowRing2:
            self.loadGlowRing()

        self.quickImpulseIval = Sequence(Func(self.glowRing2.show), LerpScaleInterval(self.glowRing2, 0.20000000000000001, Vec3(0.33000000000000002, 0.33000000000000002, 0.33000000000000002)), LerpScaleInterval(self.glowRing2, 0.25, Vec3(0.20000000000000001, 0.20000000000000001, 0.20000000000000001)), Func(self.glowRing2.hide))
        self.quickImpulseIval.start()


    def startPowerImpulse(self):
        if not self.glowRing:
            self.loadGlowRing()

        self.glowRing.show()
        self.impulseIval = Sequence(Parallel(LerpScaleInterval(self.glowRing, 0.10000000000000001, Vec3(0.20300000000000001, 0.20300000000000001, 0.20300000000000001)), LerpColorScaleInterval(self.glowRing, 0.10000000000000001, Vec4(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0.80000000000000004), Vec4(1.0, 1.0, 1.0, 0.80000000000000004), blendType = 'easeInOut')), LerpScaleInterval(self.glowRing, 0.14999999999999999, Vec3(0.19, 0.19, 0.19)), LerpScaleInterval(self.glowRing, 0.050000000000000003, Vec3(0.20200000000000001, 0.20200000000000001, 0.20200000000000001)), Parallel(LerpScaleInterval(self.glowRing, 0.029999999999999999, Vec3(0.20000000000000001, 0.20000000000000001, 0.20000000000000001)), LerpColorScaleInterval(self.glowRing, 0.40000000000000002, Vec4(1.0, 1.0, 1.0, 1.0), blendType = 'easeInOut')), Func(self.glowRing.clearColorScale))
        self.impulseIval.loop()


    def stopPowerImpulse(self):
        if self.glowRing:
            self.glowRing.hide()

        if self.impulseIval:
            self.impulseIval.finish()
            self.impulseIval = None



    def updateRechargeRing(self):
        timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId)
        self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, self.skillId)
        if timeSpentRecharging >= self.totalRechargeTime and not (self.rechargeFilled):
            self.rechargeFilled = 1
            if self.skillRingIval:
                self.skillRingIval.pause()
                self.skillRingIval = None

            self.skillRing.meterFaceHalf1.setR(0)
            self.skillRing.meterFaceHalf2.setR(180)
            self.skillRing.setScale(1.0)
            self.skillRing.clearColorScale()
            self.setGeomColor(1.0, 1.0, 1.0, 1.0)
            self.skillRingIval = Sequence(Func(base.playSfx, SkillButton.SkillRechargedSound, volume = 0.5), Parallel(LerpScaleInterval(self.skillRing, 0.10000000000000001, Vec3(1.2, 1.2, 1.2)), LerpColorScaleInterval(self.skillRing, 0.10000000000000001, Vec4(0.0, 0.75, 0.0, 1.0), Vec4(1.0, 1.0, 1.0, 1.0), blendType = 'easeInOut')), Func(localAvatar.setDefenceEffect, self.skillId), LerpScaleInterval(self.skillRing, 0.20000000000000001, Vec3(0.90000000000000002, 0.90000000000000002, 0.90000000000000002)), LerpScaleInterval(self.skillRing, 0.029999999999999999, Vec3(1.1000000000000001, 1.1000000000000001, 1.1000000000000001)), Parallel(LerpScaleInterval(self.skillRing, 0.029999999999999999, Vec3(1.0, 1.0, 1.0)), LerpColorScaleInterval(self.skillRing, 1, Vec4(1.0, 1.0, 1.0, 1.0), blendType = 'easeInOut')), Func(self.skillRing.clearColorScale))
            self.skillRingIval.start()
        elif timeSpentRecharging < self.totalRechargeTime:
            self.rechargeFilled = 0
            self.setGeomColor(0.5, 0.5, 0.5, 1.0)
            self.skillRing.update(timeSpentRecharging, self.totalRechargeTime)



    def updateSkillId(self, skillId):
        self.skillId = skillId
        if self.skillButton:
            if self.quantityLabel:
                self.quantityLabel.detachNode()

            self.skillButton.destroy()

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

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

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

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

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

        if self.showRing:
            image = None
        else:
            image = SkillButton.Image
        self.skillButton = DirectButton(parent = self, relief = None, pos = (0, 0, 0), text = ('', '', self.name), text_align = TextNode.ACenter, text_shadow = Vec4(0, 0, 0, 1), text_scale = 0.040000000000000001, text_fg = Vec4(1, 1, 1, 1), text_pos = (0.0, 0.089999999999999997), image = image, image_scale = 0.14999999999999999, image_color = image_color, geom = geom, geom_scale = geom_scale, geom_color = geomColor, command = self.callback, sortOrder = 50, extraArgs = [
            skillId])
        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel.reparentTo(self.skillButton)



    def createHotkey(self, hotkey):
        self.hotkeyLabel = DirectLabel(parent = self, relief = None, text = hotkey, text_font = PiratesGlobals.getPirateBoldOutlineFont(), text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleLarge, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, pos = (0.070000000000000007, 0, -0.059999999999999998), sortOrder = 70, state = DGG.DISABLED)
        self.hotkeyLabel.flattenLight()


    def createLock(self):
        if self.lock:
            return None

        self.lock = DirectFrame(parent = self, relief = None, image = SkillButton.SubLock, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, -0.025000000000000001), sortOrder = 99)
        if self.showIcon:
            self.lock.setColorScale(0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 1)
            self.skillButton.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1, 1)
        else:
            self.lock.setColorScale(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1, 2)
            self.skillButton.clearColorScale()
        if self.showHelp:
            self.lock.hide()



    def createHelpFrame(self, args = None):
        if self.helpFrame:
            return None

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

        baseRank = max(self.skillRank, 1)
        lvlDamageMod = WeaponGlobals.getLevelDamageModifier(localAvatar.getLevel())
        buff = WeaponGlobals.getSkillEffectFlag(self.skillId)
        dur = WeaponGlobals.getAttackDuration(self.skillId)
        effect = dur + dur * (baseRank - 1) / 4.0
        bonus = localAvatar.getSkillRankBonus(self.skillId)
        upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId)
        rank = localAvatar.getSkillRank(self.skillId)
        skillBoost = 0
        if self.skillId in ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId):
            linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId)
            skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, linkedSkillId)
            skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), linkedSkillId)
        else:
            skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, self.skillId)
            skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), self.skillId)
        manaCost = 0
        if WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX:
            manaCost = WeaponGlobals.getMojoCost(self.skillId)
            if manaCost < 0:
                amt = localAvatar.getSkillRankBonus(InventoryType.StaffConservation)
                manaCost = min(manaCost - manaCost * amt, 1.0)


        damage = 0
        loDamage = 0
        mpDamage = 0
        mpLoDamage = 0
        if WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX:
            damage = WeaponGlobals.getAttackSelfHP(self.skillId)
        elif WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX:
            mod = (1.0 + bonus) * lvlDamageMod
            damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod)
            loDamage = damage / 2
            mpDamage = int(WeaponGlobals.getAttackTargetMojo(self.skillId) * mod)
            mpLoDamage = mpDamage / 2


        try:
            skillInfo = PLocalizer.SkillDescriptions.get(self.skillId)
            skillTitle = PLocalizer.makeHeadingString(PLocalizer.InventoryTypeNames.get(self.skillId), 2)
            skillType = PLocalizer.makeHeadingString(skillInfo[0], 1)
        except:
            self.notify.error('Error getting skill info for skillId %s' % self.skillId)

        description = skillInfo[1]
        if damage < 0:
            description += ' ' + PLocalizer.DealsDamage
        elif damage > 0:
            if loDamage:
                loDamage = 0
                description += ' ' + PLocalizer.HealsDamageRange
            else:
                description += ' ' + PLocalizer.HealsDamage

        if mpDamage < 0:
            description += ' ' + PLocalizer.DealsMpDamage

        effectId = WeaponGlobals.getSkillEffectFlag(self.skillId)
        if effectId:
            description += ' ' + SkillEffectDescriptions.get(effectId)[0]

        if bonus:
            if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight:
                description += ' ' + PLocalizer.BroadsideDesc

            if self.skillId == InventoryType.CannonShoot:
                description += ' ' + PLocalizer.CannonShootDesc

            if self.skillId == InventoryType.DollAttune:
                description += ' ' + PLocalizer.MultiAttuneDesc


        if WeaponGlobals.getSkillInterrupt(self.skillId):
            description += ' ' + PLocalizer.InterruptDesc

        if WeaponGlobals.getSkillUnattune(self.skillId):
            description += ' ' + PLocalizer.UnattuneDesc

        upgradeInfo = ''
        if self.showUpgrade and rank < 5:
            if rank > 0:
                upgradeInfo = skillInfo[2]
                if upgradeInfo == '':
                    if damage < 0:
                        upgradeInfo += PLocalizer.UpgradesDamage
                    elif damage > 0:
                        upgradeInfo += PLocalizer.UpgradesHealing

                    if mpDamage < 0:
                        upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage

                    if effectId:
                        entry = SkillEffectDescriptions.get(effectId)
                        if len(entry) > 1:
                            if not damage:
                                upgradeInfo += PLocalizer.UpgradesDuration
                            else:
                                upgradeInfo += ' ' + PLocalizer.And
                            upgradeInfo += ' ' + entry[1]


                    upgradeInfo += '!'

            elif len(upgradeInfo) >= 4:
                upgradeInfo = skillInfo[3]
            else:
                upgradeInfo = PLocalizer.ClickToLearn
        elif not self.showIcon:
            unlockLevel = RepChart.getSkillUnlockLevel(self.skillId)
            if unlockLevel > 0:
                upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel


        if self.skillId in SkillComboReq and SkillComboReq[self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2:
            color = 'red'
            if rank == 0:
                color = 'red'
                upgradeInfo = ''

            description += '\n' + color + SkillComboReq[self.skillId] + '.'

        skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo
        stats = []
        if manaCost:
            stats.append(abs(manaCost))

        if damage and loDamage:
            stats.append(abs(loDamage))
            stats.append(abs(damage))
        elif damage:
            stats.append(abs(damage))

        if mpDamage:
            stats.append(abs(mpLoDamage))
            stats.append(abs(mpDamage))

        if buff == WeaponGlobals.C_CURSE:
            stats.append(WeaponGlobals.CURSED_DAM_AMP * 100)

        if buff == WeaponGlobals.C_WEAKEN:
            stats.append(WeaponGlobals.WEAKEN_PENALTY * 100)

        if effect > 0:
            stats.append(effect)

        if skillInfo[4]:
            if bonus == 0 and upgradeAmt > 0:
                if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight:
                    pass
                if not (self.skillId == InventoryType.CannonShoot):
                    bonus = upgradeAmt

            if upgradeAmt < 1.0 and upgradeAmt > 0:
                bonus *= 100

            if self.skillId == InventoryType.SailTreasureSense:
                bonus /= 2.0
            elif self.skillId == InventoryType.CutlassParry:
                bonus += WeaponGlobals.getSubtypeParryBonus(localAvatar.currentWeaponId)

            if bonus:
                stats.append(abs(bonus))


        if self.skillId == InventoryType.DollAttune:
            stats.append(rank)

        if self.skillRank:
            rankText = DirectFrame(parent = self, relief = None, text = PLocalizer.makeHeadingString(PLocalizer.Rank + ' %s' % (self.skillRank + skillBoost), 2), text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), pos = (0.45000000000000001, 0, 0), textMayChange = 1, sortOrder = 92, state = DGG.DISABLED)

        stats = [stat + 0.01 for stat in stats]

        try:
            pass
        except TypeError:
            self.notify.error('Error formatting skillDesc(%s): %s' % (self.skillId, stats))

        helpText = DirectFrame(parent = self, relief = None, text = skillDesc % stats, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 17, textMayChange = 1, state = DGG.DISABLED, sortOrder = 91)
        height = -(helpText.getHeight() + 0.01)
        if self.lock:
            height = height - 0.040000000000000001

        width = 0.55000000000000004
        self.helpFrame = BorderFrame(parent = self, state = DGG.DISABLED, frameSize = (-0.040000000000000001, width, height, 0.050000000000000003), pos = (0, 0, -0.12), sortOrder = 90)
        self.helpFrame.setBin('gui-popup', 0)
        helpText.reparentTo(self.helpFrame)
        if self.skillRank:
            rankText.reparentTo(self.helpFrame)

        if self.lock:
            self.lockedFrame = DirectFrame(parent = self.helpFrame, relief = None, pos = (0.087999999999999995, 0, height + 0.029999999999999999), image = SkillButton.SubLock, image_scale = 0.13, image_pos = (-0.055, 0, 0.012999999999999999), text = PLocalizer.VR_AuthAccess, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG13)
            self.notify.debug('locked!')

        pos = self.helpFrame.getPos(aspect2d)
        x = min(pos[0], base.a2dRight - width)
        z = max(pos[2], base.a2dBottom - height)
        self.helpFrame.setPos(aspect2d, x, 0, z)


    def showDetails(self, event):
        if self.showHelp:
            self.createHelpFrame()

        if self.showRing:
            self.skillRing.rollover(True)



    def hideDetails(self, event):
        if self.helpFrame:
            self.helpFrame.destroy()
            self.helpFrame = None

        if self.showRing:
            self.skillRing.rollover(False)



    def updateQuantity(self, quantity):
        self.quantity = quantity
        if not self.showQuantity:
            return None

        if quantity == WeaponGlobals.INF_QUANT:
            text = ''
        elif self.assocAmmo:
            assocQuantity = 0
            inv = localAvatar.getInventory()
            if inv:
                for ammoId in self.assocAmmo:
                    assocQuantity += inv.getItemQuantity(self.getAmmoCat(), ammoId)


            if quantity != assocQuantity:
                text = '%s' % assocQuantity
            else:
                text = 'x%s' % quantity
        else:
            text = 'x%s' % quantity
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel['text'] = text
        else:
            self.quantityLabel = DirectLabel(parent = NodePath(), relief = None, state = DGG.DISABLED, text = text, frameColor = (0, 0, 0, 1), frameSize = (-0.01, 0.02, -0.01, 0.025000000000000001), text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 11, pos = (0.029999999999999999, 0.0, 0.029999999999999999), text_font = PiratesGlobals.getPirateBoldOutlineFont(), sortOrder = 60)
            self.quantityLabel.flattenLight()
            self.quantityLabel.reparentTo(self)
            if self.skillButton and not self.skillButton.isEmpty():
                self.quantityLabel.reparentTo(self.skillButton)



    def getAmmoCat(self):
        pass


    def startRecharge(self):
        if not self.showRing:
            return None

        if self.isBreakAttackSkill:
            self.setGeomColor(0.5, 0.5, 0.5, 1.0)
            self.updateRechargeRing()
            return None

        if self.skillRingIval.isPlaying():
            self.createSkillRingIval()

        self.skillRingIval.start()


    def stopRecharge(self):
        if self.showRing:
            if self.isBreakAttackSkill:
                self.setGeomColor(0.5, 0.5, 0.5, 1.0)
                self.updateRechargeRing()
                return None

            if self.skillRingIval.isPlaying():
                self.skillRingIval.pause()




    def setGeomColor(self, r, g, b, a):
        self.skillButton['geom_color'] = Vec4(r, g, b, a)


    def setRingColor(self, color):
        self.skillRing.meterFaceHalf1.setColor(color[0], color[1], color[2], color[3], 100)
        self.skillRing.meterFaceHalf2.setColor(color[0], color[1], color[2], color[3], 100)


    def setShowUpgrade(self, show):
        if self.showUpgrade != show:
            self.showUpgrade = show
            if self.helpFrame:
                self.helpFrame.destroy()
                self.helpFrame = None
                self.showDetails(None)




    def setShowIcon(self, show):
        if self.showIcon != show:
            self.showIcon = show
            self.updateSkillId(self.skillId)
            if self.helpFrame:
                self.helpFrame.destroy()
                self.helpFrame = None




    def setShowLock(self, show):
        if self.showLock != show:
            self.showLock = show
            if show:
                self.createLock()
            elif self.lock:
                self.lock.destroy()
                self.lock = None
                self.skillButton.clearColorScale()




    def destroy(self):
        self.callback = None
        if self.skillRingIval:
            self.skillRingIval.pause()
            self.skillRingIval = None

        if self.quantityLabel:
            self.quantityLabel.destroy()
            self.quantityLabel = None

        if self.impulseIval:
            self.impulseIval.pause()
            self.impulseIval = None

        if self.quickImpulseIval:
            self.quickImpulseIval.pause()
            self.quickImpulseIval = None

        self.ignoreAll()
        DirectFrame.destroy(self)