def _initGUI(self):
     self.setBin('fixed', 33)
     mainGui = loader.loadModel('models/gui/gui_main')
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.checkMark = gui.find('**/generic_check')
     self.checkMark.reparentTo(self)
     self.checkMark.stash()
     self.checkMark.setScale(1.0)
     self.checkMark.setColorScale(0.0, 1.0, 0.0, 1.0)
     self.checkMark.setPos(0.02, 0.0, 0.02)
     self.checkMark.setBin('fixed', 34)
     self.skillRing = DialMeter(self,
                                wantCover=False,
                                dangerRatio=0.0,
                                meterColor=Vec4(0.9, 0.9, 0.1, 1.0),
                                baseColor=Vec4(0.15, 0.07, 0.03, 1.0),
                                completeColor=Vec4(0.1, 0.9, 0.1, 1.0))
     self.skillRing.reparentTo(self)
     self.skillRing.setScale(0.285, 0.3, 0.265)
     self.skillRing.setBin('fixed', 32)
     self.skillGlow = self.glow = OnscreenImage(
         parent=self,
         image=mainGui.find('**/icon_glow'),
         scale=(1.0, 1.0, 1.0),
         color=(1.0, 1.0, 0.6, 1.0))
     self.skillGlow.reparentTo(self)
     self.skillGlow.setBin('fixed', 31)
     self.skillGlow.stash()
     self.pirateNameBox = None
     self.pirateNameLabel = None
     return
 def __init__(self, category, width = 0.40000000000000002):
     DirectFrame.__init__(self, state = DGG.DISABLED, relief = None)
     self.initialiseoptions(ReputationMeterDial)
     self.category = category
     self.level = 0
     self.value = 0
     self.max = 0
     self.masteredIval = None
     name = self.getCategoryName()
     self.changeMeter = ChangeDialMeter(parent = self, meterColor = VBase4(0.69999999999999996, 0.0, 0.0, 1), meterColor2 = VBase4(0.69999999999999996, 0.69999999999999996, 0.0, 1), baseColor = VBase4(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 1), wantCover = 0, scale = 0.45000000000000001)
     self.changeMeter.hide()
     self.meter = DialMeter(parent = self, meterColor = VBase4(0.69999999999999996, 0.0, 0.0, 1), baseColor = VBase4(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 1), wantCover = 0, scale = 0.45000000000000001)
     self.meter.setBackwards()
     self.lastLevel = None
     self.lastExp = None
     self.mastered = False
     self.categoryLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = name, text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0, 0, 0), textMayChange = 1)
     self.levelLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = '', text_scale = 0.080000000000000002, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_font = PiratesGlobals.getPirateFont(), pos = (-0.014999999999999999, 0, -0.080000000000000002), textMayChange = 1)
     logoModel = loader.loadModel('models/gui/potcLogo')
     guiModel = loader.loadModel('models/gui/toplevel_gui')
     self.valueLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = '', text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.0, 0, -0.20000000000000001), textMayChange = 1)
     self.levelCapScroll = DirectFrame(parent = self, relief = None, image = guiModel.find('**/main_gui_quest_scroll'), image_scale = (0.13, 1.0, 0.089999999999999997), pos = (0.0, 0.0, -0.16250000000000001))
     self.levelCapScroll.hide()
     self.levelCapIcon = DirectFrame(parent = self, relief = None, image = logoModel.find('**/skull'), image_pos = (0.0, 0.0, 0.0), image_scale = 0.90000000000000002, pos = (-0.0275, 0.0, -0.105))
     self.levelCapIcon.hide()
     self.levelCapScroll.setTransparency(1)
     self.levelCapIcon.setTransparency(1)
     self.valueLabel.setTransparency(1)
 def _loadAssets(self):
     timer = None
     try:
         timer = loader.loadModel('models/gui/pir_m_gui_can_timer')
         self.timeRemaining = base.a2dTopRight.attachNewNode(
             'CannonDefenseTimeRemaining')
         self.timeRemaining.setDepthTest(True)
         self.timeRemaining.setDepthWrite(True)
         self.timeRemaining.setScale(0.75)
         model = self.timeRemaining.attachNewNode('model')
         foreGround = timer.find('**/timer')
         self.skillRing = DialMeter(model,
                                    wantCover=False,
                                    dangerRatio=0.0,
                                    meterColor=Vec4(0.11328125, 0.09375,
                                                    0.05078125, 1.0),
                                    baseColor=Vec4(1.0, 0.0, 0.0, 1.0))
         self.skillRing.setScale(0.5)
         self.skillRing.setR(180)
         self.skillRing.update(0.0, 1.0)
         foreGround.reparentTo(model)
         foreGround.setY(-0.1)
         self.__createWaveText(model)
         self.__createWaveLabel(model)
         min = Point3()
         max = Point3()
         model.calcTightBounds(min, max)
         size = max - min
         model.setPos(-size[0] / 2.0, 0, -size[2] / 2.0)
     finally:
         if timer:
             timer.removeNode()
     return
示例#4
0
 def __init__(self, parent, **kw):
     DirectFrame.__init__(self, parent, **None)
     self.initialiseoptions(VitaeMeter)
     toplevel_gui = loader.loadModel('models/gui/toplevel_gui')
     self.vitaeDial = DialMeter(parent=self,
                                meterColor=Vec4(0.80000000000000004,
                                                0.20000000000000001,
                                                0.20000000000000001, 1),
                                baseColor=Vec4(0, 0, 0, 1),
                                scale=0.28000000000000003)
     icon = toplevel_gui.find('**/morale_skull*')
     self.vitaeIcon = DirectFrame(parent=self,
                                  state=DGG.NORMAL,
                                  relief=None,
                                  image=icon,
                                  image_scale=0.625)
     detailLabel = DirectLabel(
         relief=None,
         state=DGG.DISABLED,
         text=PLocalizer.VitaeDesc,
         text_align=TextNode.ALeft,
         text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
         text_fg=PiratesGuiGlobals.TextFG1,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         pos=(0.0, 0, -0.025000000000000001),
         textMayChange=0,
         sortOrder=91)
     height = -(detailLabel.getHeight() + 0.01)
     width = max(0.25, detailLabel.getWidth() + 0.040000000000000001)
     self.helpBox = BorderFrame(parent=self,
                                state=DGG.DISABLED,
                                modelName='general_frame_f',
                                frameSize=(-0.040000000000000001, width,
                                           height, 0.050000000000000003),
                                pos=(0.050000000000000003, 0,
                                     -0.050000000000000003),
                                sortOrder=90)
     detailLabel.reparentTo(self.helpBox)
     self.helpBox.hide()
     self.helpBox.setClipPlaneOff()
     self.meterLabel = DirectLabel(
         parent=self.vitaeDial,
         relief=None,
         pos=(0, 0, -0.45000000000000001),
         text=PLocalizer.Vitae,
         text_scale=0.20000000000000001,
         text_align=TextNode.ACenter,
         text_fg=PiratesGuiGlobals.TextFG1,
         text_shadow=PiratesGuiGlobals.TextShadow,
         text_font=PiratesGlobals.getPirateOutlineFont(),
         textMayChange=1)
     self.vitaeIcon.bind(DGG.WITHIN, self.showDetails)
     self.vitaeIcon.bind(DGG.WITHOUT, self.hideDetails)
 def _loadAssets(self):
     timer = None
     
     try:
         timer = loader.loadModel('models/gui/pir_m_gui_can_timer')
         self.timeRemaining = base.a2dTopRight.attachNewNode('CannonDefenseTimeRemaining')
         self.timeRemaining.setDepthTest(True)
         self.timeRemaining.setDepthWrite(True)
         self.timeRemaining.setScale(0.75)
         model = self.timeRemaining.attachNewNode('model')
         foreGround = timer.find('**/timer')
         self.skillRing = DialMeter(model, wantCover = False, dangerRatio = 0.0, meterColor = Vec4(0.11328125, 0.09375, 0.05078125, 1.0), baseColor = Vec4(1.0, 0.0, 0.0, 1.0))
         self.skillRing.setScale(0.5)
         self.skillRing.setR(180)
         self.skillRing.update(0.0, 1.0)
         foreGround.reparentTo(model)
         foreGround.setY(-0.10000000000000001)
         self._CannonDefenseTimeRemainingUI__createWaveText(model)
         self._CannonDefenseTimeRemainingUI__createWaveLabel(model)
         min = Point3()
         max = Point3()
         model.calcTightBounds(min, max)
         size = max - min
         model.setPos(-size[0] / 2.0, 0, -size[2] / 2.0)
     finally:
         if timer:
             timer.removeNode()
 def makeIcons(self):
     self.Background.copyTo(self)
     self.dial = DialMeter(parent = self, meterColor = Vec4(0.29999999999999999, 0.0, 0.80000000000000004, 1), baseColor = Vec4(0, 0, 0, 1), scale = 0.17000000000000001, sortOrder = 0)
     if self.effectId in buffTable:
         info = buffTable.get(self.effectId)
     else:
         info = buffTable.get(WeaponGlobals.C_UNKNOWN_EFFECT)
     self.myIcon = DirectButton(parent = self, relief = None, geom = self.Card.find('**/' + info[0]), geom_scale = self.iconScale, sortOrder = 1)
     self.myIcon.bind(DGG.ENTER, self.showDetails)
     self.myIcon.bind(DGG.EXIT, self.hideDetails)
     self.updateIconInfo()
示例#7
0
 def makeIcons(self):
     self.Background.copyTo(self)
     self.dial = DialMeter(parent=self,
                           meterColor=Vec4(0.29999999999999999, 0.0,
                                           0.80000000000000004, 1),
                           baseColor=Vec4(0, 0, 0, 1),
                           scale=0.17000000000000001,
                           sortOrder=0)
     if self.effectId in buffTable:
         info = buffTable.get(self.effectId)
     else:
         info = buffTable.get(WeaponGlobals.C_UNKNOWN_EFFECT)
     self.myIcon = DirectButton(parent=self,
                                relief=None,
                                geom=self.Card.find('**/' + info[0]),
                                geom_scale=self.iconScale,
                                sortOrder=1)
     self.myIcon.bind(DGG.ENTER, self.showDetails)
     self.myIcon.bind(DGG.EXIT, self.hideDetails)
     self.updateIconInfo()
class VitaeMeter(DirectFrame):

    def __init__(self, parent, **kw):
        DirectFrame.__init__(self, parent)
        self.initialiseoptions(VitaeMeter)
        toplevel_gui = loader.loadModel('models/gui/toplevel_gui')
        self.vitaeDial = DialMeter(parent = self, meterColor = Vec4(0.80000000000000004, 0.20000000000000001, 0.20000000000000001, 1), baseColor = Vec4(0, 0, 0, 1), scale = 0.28000000000000003)
        icon = toplevel_gui.find('**/morale_skull*')
        self.vitaeIcon = DirectFrame(parent = self, state = DGG.NORMAL, relief = None, image = icon, image_scale = 0.625)
        detailLabel = DirectLabel(relief = None, state = DGG.DISABLED, text = PLocalizer.VitaeDesc, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), pos = (0.0, 0, -0.025000000000000001), textMayChange = 0, sortOrder = 91)
        height = -(detailLabel.getHeight() + 0.01)
        width = max(0.25, detailLabel.getWidth() + 0.040000000000000001)
        self.helpBox = BorderFrame(parent = self, state = DGG.DISABLED, modelName = 'general_frame_f', frameSize = (-0.040000000000000001, width, height, 0.050000000000000003), pos = (0.050000000000000003, 0, -0.050000000000000003), sortOrder = 90)
        detailLabel.reparentTo(self.helpBox)
        self.helpBox.hide()
        self.helpBox.setClipPlaneOff()
        self.meterLabel = DirectLabel(parent = self.vitaeDial, relief = None, pos = (0, 0, -0.45000000000000001), text = PLocalizer.Vitae, text_scale = 0.20000000000000001, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateOutlineFont(), textMayChange = 1)
        self.vitaeIcon.bind(DGG.WITHIN, self.showDetails)
        self.vitaeIcon.bind(DGG.WITHOUT, self.hideDetails)


    def showDetails(self, event):
        self.helpBox.show()


    def hideDetails(self, event):
        self.helpBox.hide()


    def update(self, level, range, val):
        self.vitaeDial.hide()
        Range = range * 1.0009999999999999
        if level > 0:
            self.vitaeDial.update(val, Range)
            self.vitaeDial.show()
 def _initGUI(self):
     self.setBin('fixed', 33)
     mainGui = loader.loadModel('models/gui/gui_main')
     gui = loader.loadModel('models/gui/toplevel_gui')
     self.checkMark = gui.find('**/generic_check')
     self.checkMark.reparentTo(self)
     self.checkMark.stash()
     self.checkMark.setScale(1.0)
     self.checkMark.setColorScale(0.0, 1.0, 0.0, 1.0)
     self.checkMark.setPos(0.02, 0.0, 0.02)
     self.checkMark.setBin('fixed', 34)
     self.skillRing = DialMeter(self, wantCover = False, dangerRatio = 0.0, meterColor = Vec4(0.90000000000000002, 0.90000000000000002, 0.10000000000000001, 1.0), baseColor = Vec4(0.14999999999999999, 0.070000000000000007, 0.029999999999999999, 1.0), completeColor = Vec4(0.10000000000000001, 0.90000000000000002, 0.10000000000000001, 1.0))
     self.skillRing.reparentTo(self)
     self.skillRing.setScale(0.28499999999999998, 0.29999999999999999, 0.26500000000000001)
     self.skillRing.setBin('fixed', 32)
     self.skillGlow = OnscreenImage(parent = self, image = mainGui.find('**/icon_glow'), scale = (1.0, 1.0, 1.0), color = (1.0, 1.0, 0.59999999999999998, 1.0))
     self.glow = OnscreenImage(parent = self, image = mainGui.find('**/icon_glow'), scale = (1.0, 1.0, 1.0), color = (1.0, 1.0, 0.59999999999999998, 1.0))
     self.skillGlow.reparentTo(self)
     self.skillGlow.setBin('fixed', 31)
     self.skillGlow.stash()
     self.pirateNameBox = None
     self.pirateNameLabel = None
class ReputationMeterDial(DirectFrame):
    def __init__(self, category, width=0.40000000000000002):
        DirectFrame.__init__(self, state=DGG.DISABLED, relief=None)
        self.initialiseoptions(ReputationMeterDial)
        self.category = category
        self.level = 0
        self.value = 0
        self.max = 0
        self.masteredIval = None
        name = self.getCategoryName()
        self.changeMeter = ChangeDialMeter(
            parent=self,
            meterColor=VBase4(0.69999999999999996, 0.0, 0.0, 1),
            meterColor2=VBase4(0.69999999999999996, 0.69999999999999996, 0.0,
                               1),
            baseColor=VBase4(0.10000000000000001, 0.10000000000000001,
                             0.10000000000000001, 1),
            wantCover=0,
            scale=0.45000000000000001)
        self.changeMeter.hide()
        self.meter = DialMeter(parent=self,
                               meterColor=VBase4(0.69999999999999996, 0.0, 0.0,
                                                 1),
                               baseColor=VBase4(0.10000000000000001,
                                                0.10000000000000001,
                                                0.10000000000000001, 1),
                               wantCover=0,
                               scale=0.45000000000000001)
        self.meter.setBackwards()
        self.lastLevel = None
        self.lastExp = None
        self.mastered = False
        self.categoryLabel = DirectLabel(
            parent=self,
            state=DGG.DISABLED,
            relief=None,
            text=name,
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0, 0, 0),
            textMayChange=1)
        self.levelLabel = DirectLabel(parent=self,
                                      state=DGG.DISABLED,
                                      relief=None,
                                      text='',
                                      text_scale=0.080000000000000002,
                                      text_align=TextNode.ACenter,
                                      text_fg=PiratesGuiGlobals.TextFG2,
                                      text_font=PiratesGlobals.getPirateFont(),
                                      pos=(-0.014999999999999999, 0,
                                           -0.080000000000000002),
                                      textMayChange=1)
        logoModel = loader.loadModel('models/gui/potcLogo')
        guiModel = loader.loadModel('models/gui/toplevel_gui')
        self.valueLabel = DirectLabel(
            parent=self,
            state=DGG.DISABLED,
            relief=None,
            text='',
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.0, 0, -0.20000000000000001),
            textMayChange=1)
        self.levelCapScroll = DirectFrame(
            parent=self,
            relief=None,
            image=guiModel.find('**/main_gui_quest_scroll'),
            image_scale=(0.13, 1.0, 0.089999999999999997),
            pos=(0.0, 0.0, -0.16250000000000001))
        self.levelCapScroll.hide()
        self.levelCapIcon = DirectFrame(parent=self,
                                        relief=None,
                                        image=logoModel.find('**/skull'),
                                        image_pos=(0.0, 0.0, 0.0),
                                        image_scale=0.90000000000000002,
                                        pos=(-0.0275, 0.0, -0.105))
        self.levelCapIcon.hide()
        self.levelCapScroll.setTransparency(1)
        self.levelCapIcon.setTransparency(1)
        self.valueLabel.setTransparency(1)

    def destroy(self):
        DirectFrame.destroy(self)
        if self.masteredIval:
            self.masteredIval.pause()
            self.masteredIval = None

    def hideMasterOrnament(self):
        self.levelCapScroll.hide()
        self.levelCapIcon.hide()
        self.levelLabel.show()

    def showMasterOrnament(self):
        self.levelCapScroll.show()
        self.levelCapIcon.show()
        self.levelLabel.hide()
        self.mastered = True

    def masteredFX(self):
        if self.masteredIval:
            self.masteredIval.start()
            return None

        startColor = Vec4(1.0, 1.0, 1.0, 0.0)
        endColor = Vec4(1.0, 1.0, 1.0, 1.0)
        duration = 1.5
        fade = Parallel(
            LerpColorScaleInterval(self.levelCapScroll,
                                   duration,
                                   endColor,
                                   startColor,
                                   blendType='easeInOut'),
            LerpColorScaleInterval(self.levelCapIcon,
                                   duration,
                                   endColor,
                                   startColor,
                                   blendType='easeInOut'),
            LerpColorScaleInterval(self.valueLabel,
                                   duration,
                                   endColor,
                                   startColor,
                                   blendType='easeInOut'))
        startScale = Vec3(0.75, 0.75, 0.75)
        endScale = Vec3(1.0, 1.0, 1.0)
        duration = 1.0
        scale = Parallel(
            LerpScaleInterval(self.levelCapScroll,
                              duration,
                              endScale,
                              startScale,
                              blendType='easeInOut'),
            LerpScaleInterval(self.levelCapIcon,
                              duration,
                              endScale,
                              startScale * 0.10000000000000001,
                              blendType='easeInOut'),
            LerpScaleInterval(self.valueLabel,
                              duration,
                              endScale,
                              startScale,
                              blendType='easeInOut'))
        self.masteredIval = Parallel(fade, scale)
        self.masteredIval.start()

    def update(self, value, updateLocal=0):
        if self.mastered:
            return None

        self.value = value
        (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(
            self.category, value)
        self.max = ReputationGlobals.getReputationNeededToLevel(
            self.category, level)
        self.levelLabel['text'] = '%s' % level
        if self.category == InventoryType.OverallRep:
            levelCap = ReputationGlobals.GlobalLevelCap
            if updateLocal and level != self.level:
                localAvatar.setLevel(level)

        else:
            levelCap = ReputationGlobals.LevelCap
        self.level = level
        if level == levelCap:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.valueLabel['text_scale'] = 0.042999999999999997
            self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level
            self.categoryLabel.hide()
            self.meter.meterFaceHalf1.hide()
            self.meter.meterFaceHalf2.hide()
            self.meter.meterFace.setColor(0.10000000000000001,
                                          0.40000000000000002,
                                          0.10000000000000001, 1.0)
            self.valueLabel.setZ(0.029999999999999999)
            self.showMasterOrnament()
            self.masteredFX()
        else:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.meter.show()
            self.categoryLabel.show()
            self.valueLabel['text'] = '%s / %s' % (leftoverValue, self.max)
            self.valueLabel['text_scale'] = PiratesGuiGlobals.TextScaleLarge
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG2
            self.valueLabel.setZ(0.0)
            self.meter.update(leftoverValue, self.max)
            self.hideMasterOrnament()
            if self.lastLevel == None:
                self.lastLevel = level

            if self.lastExp == None:
                if hasattr(base, 'localAvatar'):
                    self.lastExp = localAvatar.getInventory().getReputation(
                        self.category)

            if self.lastExp:
                expChange = value - self.lastExp
                if expChange and localAvatar.getGameState() != 'Fishing':
                    localAvatar.guiMgr.gameGui.createExpAlert(
                        expChange, 4.0, Vec3(-0.93000000000000005, 0.0, 0.75),
                        Vec3(0.0, 0.0, 0.25))

            if self.lastLevel != level:
                self.lastLevel = level
                glowFrameColor = Vec4(0.69999999999999996, 0.0, 0.0, 1.0)
                glowLevelColor = Vec4(0.80000000000000004, 0.0, 0.0, 1.0)
                startFrameColor = self.meter.meterFace.getColor()
                startLevelColor = Vec4(0.90000000000000002,
                                       0.80000000000000004, 0.63, 1.0)
                startFrameScale = self.meter.meterFace.getScale()
                startLevelScale = self.levelLabel.getScale()
                scale = Vec3(1.2, 1.2, 1.2)
                objFrame = self.meter.meterFace
                objLevel = self.levelLabel
                levelUpIval = Sequence(
                    Func(self.meter.meterFaceHalf1.hide),
                    Func(self.meter.meterFaceHalf2.hide),
                    Parallel(
                        LerpColorInterval(objFrame,
                                          3.0,
                                          startFrameColor,
                                          glowFrameColor,
                                          blendType='easeInOut'),
                        LerpColorInterval(objLevel,
                                          3.0,
                                          startLevelColor,
                                          glowLevelColor,
                                          blendType='easeInOut'),
                        Sequence(
                            LerpScaleInterval(objLevel,
                                              0.25,
                                              scale,
                                              startFrameScale,
                                              blendType='easeInOut'),
                            LerpScaleInterval(objLevel,
                                              2.0,
                                              startFrameScale,
                                              blendType='easeInOut'))),
                    Func(self.meter.meterFaceHalf1.show),
                    Func(self.meter.meterFaceHalf2.show),
                    Func(objLevel.clearColor))
                levelUpIval.start()
            elif self.lastExp is not None:
                if self.lastExp == value:
                    return None

            self.lastExp = value
            glowFrameColor = Vec4(1.0, 0, 0, 1.0)
            startFrameColorA = self.meter.meterFaceHalf1.getColor()
            startFrameColorB = self.meter.meterFaceHalf2.getColor()
            objFrameA = self.meter.meterFaceHalf1
            objFrameB = self.meter.meterFaceHalf2
            objFrameC = self.meter.meterFace
            if leftoverValue and float(self.max) / float(leftoverValue) > 2.0:
                expUpIval = Sequence(
                    LerpColorScaleInterval(objFrameA,
                                           0.20000000000000001,
                                           glowFrameColor,
                                           blendType='easeInOut'),
                    Wait(0.20000000000000001),
                    LerpColorScaleInterval(objFrameA,
                                           0.5,
                                           startFrameColorA,
                                           blendType='easeInOut'),
                    LerpColorScaleInterval(objFrameA,
                                           0.10000000000000001,
                                           glowFrameColor,
                                           blendType='easeInOut'),
                    Wait(0.10000000000000001),
                    LerpColorScaleInterval(objFrameA,
                                           0.29999999999999999,
                                           startFrameColorA,
                                           blendType='easeInOut'))
            else:
                expUpIval = Sequence(
                    Parallel(
                        LerpColorScaleInterval(objFrameA,
                                               0.20000000000000001,
                                               glowFrameColor,
                                               blendType='easeInOut'),
                        LerpColorScaleInterval(objFrameB,
                                               0.20000000000000001,
                                               glowFrameColor,
                                               blendType='easeInOut')),
                    Wait(0.20000000000000001),
                    Parallel(
                        LerpColorScaleInterval(objFrameA,
                                               0.5,
                                               startFrameColorA,
                                               blendType='easeInOut'),
                        LerpColorScaleInterval(objFrameB,
                                               0.5,
                                               startFrameColorA,
                                               blendType='easeInOut')),
                    Parallel(
                        LerpColorScaleInterval(objFrameA,
                                               0.10000000000000001,
                                               glowFrameColor,
                                               blendType='easeInOut'),
                        LerpColorScaleInterval(objFrameB,
                                               0.10000000000000001,
                                               glowFrameColor,
                                               blendType='easeInOut')),
                    Wait(0.10000000000000001),
                    Parallel(
                        LerpColorScaleInterval(objFrameA,
                                               0.29999999999999999,
                                               startFrameColorA,
                                               blendType='easeInOut'),
                        LerpColorScaleInterval(objFrameB,
                                               0.29999999999999999,
                                               startFrameColorA,
                                               blendType='easeInOut')))
            expUpIval.start()

    def updateChange(self, value, newValue):
        self.value = value
        (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(
            self.category, value + newValue)
        self.max = ReputationGlobals.getReputationNeededToLevel(
            self.category, level)
        self.levelLabel['text'] = '%s' % level
        oldValue = leftoverValue - newValue
        if oldValue < 0:
            oldValue = 0

        if self.category == InventoryType.OverallRep:
            levelCap = ReputationGlobals.GlobalLevelCap
        else:
            levelCap = ReputationGlobals.LevelCap
        if level == levelCap:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.valueLabel['text_scale'] = 0.042999999999999997
            self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level
            self.categoryLabel.hide()
            self.meter.meterFaceHalf1.hide()
            self.meter.meterFaceHalf2.hide()
            self.meter.meterFace.setColor(0.10000000000000001,
                                          0.40000000000000002,
                                          0.10000000000000001, 1.0)
            self.valueLabel.setZ(0.029999999999999999)
            self.showMasterOrnament()
            self.masteredFX()
        else:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.categoryLabel.show()
            self.valueLabel.hide()
            self.changeMeter.update(oldValue, leftoverValue, self.max)
            self.changeMeter.show()
            self.meter.hide()
            self.hideMasterOrnament()

    def setCategory(self, category):
        self.category = category
        name = self.getCategoryName()
        self.categoryLabel['text'] = name

    def getCategory(self):
        return self.category

    def getCategoryName(self):
        return PLocalizer.InventoryTypeNames[self.category]
class BuffIcon(DirectFrame):
    Background = None
    Card = None

    def __init__(self, parent, effectId, duration, attackerId, **kw):
        optiondefs = (('relief', None, None),)
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, parent)
        self.initialiseoptions(BuffIcon)
        if not self.Background:
            self.Background = loader.loadModel('models/gui/lookout_gui').find('**/lookout_submit')
            self.Background.setScale(0.33000000000000002)

        if not self.Card:
            self.Card = loader.loadModel('models/textureCards/buff_icons')

        self.myIcon = None
        self.detailFrame = None
        self.dial = None
        self.iconScale = 0.070000000000000007
        self.effectId = effectId
        self.maxDuration = duration
        self.timeLeft = duration
        self.lastTimestamp = None
        self.attackerId = attackerId
        self.setDepthWrite(0)
        self.setFogOff()
        self.setLightOff()
        self.setBin('gui-fixed', 0)


    def makeIcons(self):
        self.Background.copyTo(self)
        self.dial = DialMeter(parent = self, meterColor = Vec4(0.29999999999999999, 0.0, 0.80000000000000004, 1), baseColor = Vec4(0, 0, 0, 1), scale = 0.17000000000000001, sortOrder = 0)
        if self.effectId in buffTable:
            info = buffTable.get(self.effectId)
        else:
            info = buffTable.get(WeaponGlobals.C_UNKNOWN_EFFECT)
        self.myIcon = DirectButton(parent = self, relief = None, geom = self.Card.find('**/' + info[0]), geom_scale = self.iconScale, sortOrder = 1)
        self.myIcon.bind(DGG.ENTER, self.showDetails)
        self.myIcon.bind(DGG.EXIT, self.hideDetails)
        self.updateIconInfo()


    def makeDetails(self):
        if self.detailFrame:
            return None

        normalScale = 0.97307200000000005
        parent = self.getParent()
        if parent:
            for i in range(0, 2):
                parent = parent.getParent()
                if not parent:
                    break
                    continue


        if parent:
            parentScale = parent.getScale()[0]
        else:
            parentScale = normalScale
        durationStr = str(int(self.maxDuration))
        if self.effectId in buffTable:
            text = buffTable[self.effectId][1] + PLocalizer.BuffDuration % durationStr
        else:
            text = buffTable[WeaponGlobals.C_UNKNOWN_EFFECT][1] + PLocalizer.BuffDuration % durationStr
        self.detailBox = DirectLabel(state = DGG.DISABLED, relief = None, text = text, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleExtraLarge * normalScale / parentScale, text_fg = (1, 1, 1, 1), text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1)
        height = -(self.detailBox.getHeight() + 0.01)
        width = max(0.25, self.detailBox.getWidth() + 0.040000000000000001)
        self.detailFrame = BorderFrame(parent = self.myIcon, state = DGG.DISABLED, frameSize = (-0.040000000000000001, width, height, 0.070000000000000007), pos = (0.050000000000000003, 0, -0.050000000000000003))
        self.detailBox.reparentTo(self.detailFrame)
        self.detailFrame.setBin('gui-popup', 0)
        self.detailFrame.hide()


    def showDetails(self, event):
        self.makeDetails()
        self.detailFrame.show()
        self.updateIconInfo()


    def hideDetails(self, event):
        if self.detailFrame:
            self.detailFrame.hide()



    def updateIconInfo(self):
        if self.lastTimestamp == None:
            timeOffset = 0.0
        else:
            timeOffset = globalClockDelta.localElapsedTime(self.lastTimestamp)
        duration = max(0.0, self.timeLeft - timeOffset)
        self.dial.update(duration, self.maxDuration)
        if self.detailFrame and not self.detailFrame.isHidden():
            if duration > 0:
                durationStr = PLocalizer.BuffDuration % str(int(duration) + 1)
            else:
                durationStr = ''
            if self.effectId in buffTable:
                text = buffTable[self.effectId][1] + durationStr
            else:
                text = buffTable[WeaponGlobals.C_UNKNOWN_EFFECT][1] + durationStr
            self.detailBox['text'] = text



    def destroy(self):
        DirectFrame.destroy(self)
示例#12
0
class RepairGameButton(GuiButton):
    def __init__(self, parent, **kw):
        optiondefs = (('nodePath', None, None), ('image_scale', (1.0, 1.0,
                                                                 1.0), None))
        self.defineoptions(kw, optiondefs)
        GuiButton.__init__(self, parent)
        self.initialiseoptions(RepairGameButton)
        self.disabledStateNode = self.stateNodePath[3].getChild(0)
        self.downStateNode = self.stateNodePath[1].getChild(0)
        self.overStateNode = self.stateNodePath[2].getChild(0)
        self.inProgress = False
        self._initGUI()

    def _initGUI(self):
        self.setBin('fixed', 33)
        mainGui = loader.loadModel('models/gui/gui_main')
        gui = loader.loadModel('models/gui/toplevel_gui')
        self.checkMark = gui.find('**/generic_check')
        self.checkMark.reparentTo(self)
        self.checkMark.stash()
        self.checkMark.setScale(1.0)
        self.checkMark.setColorScale(0.0, 1.0, 0.0, 1.0)
        self.checkMark.setPos(0.02, 0.0, 0.02)
        self.checkMark.setBin('fixed', 34)
        self.skillRing = DialMeter(self,
                                   wantCover=False,
                                   dangerRatio=0.0,
                                   meterColor=Vec4(0.90000000000000002,
                                                   0.90000000000000002,
                                                   0.10000000000000001, 1.0),
                                   baseColor=Vec4(0.14999999999999999,
                                                  0.070000000000000007,
                                                  0.029999999999999999, 1.0),
                                   completeColor=Vec4(0.10000000000000001,
                                                      0.90000000000000002,
                                                      0.10000000000000001,
                                                      1.0))
        self.skillRing.reparentTo(self)
        self.skillRing.setScale(0.28499999999999998, 0.29999999999999999,
                                0.26500000000000001)
        self.skillRing.setBin('fixed', 32)
        self.skillGlow = OnscreenImage(parent=self,
                                       image=mainGui.find('**/icon_glow'),
                                       scale=(1.0, 1.0, 1.0),
                                       color=(1.0, 1.0, 0.59999999999999998,
                                              1.0))
        self.glow = OnscreenImage(parent=self,
                                  image=mainGui.find('**/icon_glow'),
                                  scale=(1.0, 1.0, 1.0),
                                  color=(1.0, 1.0, 0.59999999999999998, 1.0))
        self.skillGlow.reparentTo(self)
        self.skillGlow.setBin('fixed', 31)
        self.skillGlow.stash()
        self.pirateNameBox = None
        self.pirateNameLabel = None

    def showGlow(self):
        self.inProgress = False
        if self.pirateNameLabel == None and self.checkMark.isStashed():
            self.skillGlow.unstash()

    def hideGlow(self):
        self.inProgress = True
        self.skillGlow.stash()

    def setProgress(self, percent):
        self.skillGlow.stash()
        ratio = max(0.0, percent / 100.0)
        if ratio >= 1.0:
            if self.checkMark.isStashed():
                self.checkMark.unstash()

        elif not self.checkMark.isStashed():
            self.checkMark.stash()

        if self.pirateNameLabel == None and not (self.inProgress):
            self.skillGlow.unstash()

        self.skillRing.update(ratio, 1.0)
        self.skillRing.wrtReparentTo(self.getParent())
        self.reparentTo(self.getParent())

    def updatePirateNameBox(self, pirateName):
        if self.pirateNameLabel != None and self.pirateNameLabel[
                'text'] != pirateName:
            if self.pirateNameBox:
                self.pirateNameBox.destroy()

            if self.pirateNameLabel:
                self.pirateNameLabel.destroy()

            self.pirateNameBox = None
            self.pirateNameLabel = None

        if pirateName != '':
            if self.pirateNameBox:
                pass
            if not (self.pirateNameLabel['text'] == pirateName):
                self.createPirateNameBox(pirateName)

    def createPirateNameBox(self, pirateName):
        self.pirateNameLabel = DirectLabel(
            relief=None,
            state=DGG.DISABLED,
            text=pirateName,
            text_align=TextNode.ACenter,
            text_scale=PiratesGuiGlobals.TextScaleMed,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_wordwrap=12,
            textMayChange=0,
            sortOrder=91)
        self.pirateNameLabel.setBin('fixed', 33)
        height = self.pirateNameLabel.getHeight()
        width = self.pirateNameLabel.getWidth() + 0.050000000000000003
        pos = [0.0, 0.0, height / 2 - 0.035000000000000003]
        fs = [
            -(width / 2 + 0.01), width / 2 + 0.01,
            -(height / 2 + 0.014999999999999999),
            height / 2 + 0.014999999999999999
        ]
        self.pirateNameBox = BorderFrame(parent=self,
                                         state=DGG.DISABLED,
                                         frameSize=(fs[0], fs[1], fs[2],
                                                    fs[3]),
                                         modelName='general_frame_f',
                                         pos=(0.0, 0.0, 0.0))
        self.pirateNameLabel.reparentTo(self.pirateNameBox)
        self.pirateNameLabel.setPos(pos[0], pos[1], pos[2])
        self.pirateNameBox.setClipPlaneOff()
        pos = self.pirateNameBox.getPos(aspect2d)
        x = min(pos[0], base.a2dRight - width)
        z = max(pos[2], base.a2dBottom - height)
        self.pirateNameBox.setPos(aspect2d, x, 0, z - 0.17499999999999999)
        self.pirateNameBox.flattenLight()
        self.pirateNameBox.setBin('fixed', 32)
        self.pirateNameBox.reparentTo(self)
class RepairGameButton(GuiButton):
    
    def __init__(self, parent, **kw):
        optiondefs = (('nodePath', None, None), ('image_scale', (1.0, 1.0, 1.0), None))
        self.defineoptions(kw, optiondefs)
        GuiButton.__init__(self, parent)
        self.initialiseoptions(RepairGameButton)
        self.disabledStateNode = self.stateNodePath[3].getChild(0)
        self.downStateNode = self.stateNodePath[1].getChild(0)
        self.overStateNode = self.stateNodePath[2].getChild(0)
        self.inProgress = False
        self._initGUI()

    
    def _initGUI(self):
        self.setBin('fixed', 33)
        mainGui = loader.loadModel('models/gui/gui_main')
        gui = loader.loadModel('models/gui/toplevel_gui')
        self.checkMark = gui.find('**/generic_check')
        self.checkMark.reparentTo(self)
        self.checkMark.stash()
        self.checkMark.setScale(1.0)
        self.checkMark.setColorScale(0.0, 1.0, 0.0, 1.0)
        self.checkMark.setPos(0.02, 0.0, 0.02)
        self.checkMark.setBin('fixed', 34)
        self.skillRing = DialMeter(self, wantCover = False, dangerRatio = 0.0, meterColor = Vec4(0.90000000000000002, 0.90000000000000002, 0.10000000000000001, 1.0), baseColor = Vec4(0.14999999999999999, 0.070000000000000007, 0.029999999999999999, 1.0), completeColor = Vec4(0.10000000000000001, 0.90000000000000002, 0.10000000000000001, 1.0))
        self.skillRing.reparentTo(self)
        self.skillRing.setScale(0.28499999999999998, 0.29999999999999999, 0.26500000000000001)
        self.skillRing.setBin('fixed', 32)
        self.skillGlow = OnscreenImage(parent = self, image = mainGui.find('**/icon_glow'), scale = (1.0, 1.0, 1.0), color = (1.0, 1.0, 0.59999999999999998, 1.0))
        self.glow = OnscreenImage(parent = self, image = mainGui.find('**/icon_glow'), scale = (1.0, 1.0, 1.0), color = (1.0, 1.0, 0.59999999999999998, 1.0))
        self.skillGlow.reparentTo(self)
        self.skillGlow.setBin('fixed', 31)
        self.skillGlow.stash()
        self.pirateNameBox = None
        self.pirateNameLabel = None

    
    def showGlow(self):
        self.inProgress = False
        if self.pirateNameLabel == None and self.checkMark.isStashed():
            self.skillGlow.unstash()
        

    
    def hideGlow(self):
        self.inProgress = True
        self.skillGlow.stash()

    
    def setProgress(self, percent):
        self.skillGlow.stash()
        ratio = max(0.0, percent / 100.0)
        if ratio >= 1.0:
            if self.checkMark.isStashed():
                self.checkMark.unstash()
            
        elif not self.checkMark.isStashed():
            self.checkMark.stash()
        
        if self.pirateNameLabel == None and not (self.inProgress):
            self.skillGlow.unstash()
        
        self.skillRing.update(ratio, 1.0)
        self.skillRing.wrtReparentTo(self.getParent())
        self.reparentTo(self.getParent())

    
    def updatePirateNameBox(self, pirateName):
        if self.pirateNameLabel != None and self.pirateNameLabel['text'] != pirateName:
            if self.pirateNameBox:
                self.pirateNameBox.destroy()
            
            if self.pirateNameLabel:
                self.pirateNameLabel.destroy()
            
            self.pirateNameBox = None
            self.pirateNameLabel = None
        
        if pirateName != '':
            if self.pirateNameBox:
                pass
            if not (self.pirateNameLabel['text'] == pirateName):
                self.createPirateNameBox(pirateName)
            

    
    def createPirateNameBox(self, pirateName):
        self.pirateNameLabel = DirectLabel(relief = None, state = DGG.DISABLED, text = pirateName, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleMed, text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 12, textMayChange = 0, sortOrder = 91)
        self.pirateNameLabel.setBin('fixed', 33)
        height = self.pirateNameLabel.getHeight()
        width = self.pirateNameLabel.getWidth() + 0.050000000000000003
        pos = [
            0.0,
            0.0,
            height / 2 - 0.035000000000000003]
        fs = [
            -(width / 2 + 0.01),
            width / 2 + 0.01,
            -(height / 2 + 0.014999999999999999),
            height / 2 + 0.014999999999999999]
        self.pirateNameBox = BorderFrame(parent = self, state = DGG.DISABLED, frameSize = (fs[0], fs[1], fs[2], fs[3]), modelName = 'general_frame_f', pos = (0.0, 0.0, 0.0))
        self.pirateNameLabel.reparentTo(self.pirateNameBox)
        self.pirateNameLabel.setPos(pos[0], pos[1], pos[2])
        self.pirateNameBox.setClipPlaneOff()
        pos = self.pirateNameBox.getPos(aspect2d)
        x = min(pos[0], base.a2dRight - width)
        z = max(pos[2], base.a2dBottom - height)
        self.pirateNameBox.setPos(aspect2d, x, 0, z - 0.17499999999999999)
        self.pirateNameBox.flattenLight()
        self.pirateNameBox.setBin('fixed', 32)
        self.pirateNameBox.reparentTo(self)
class CannonDefenseTimeRemainingUI:
    __module__ = __name__

    def __init__(self):
        self.timeRemaining = None
        self.skillRing = None
        self._loadAssets()
        return

    def _loadAssets(self):
        timer = None
        try:
            timer = loader.loadModel('models/gui/pir_m_gui_can_timer')
            self.timeRemaining = base.a2dTopRight.attachNewNode(
                'CannonDefenseTimeRemaining')
            self.timeRemaining.setDepthTest(True)
            self.timeRemaining.setDepthWrite(True)
            self.timeRemaining.setScale(0.75)
            model = self.timeRemaining.attachNewNode('model')
            foreGround = timer.find('**/timer')
            self.skillRing = DialMeter(model,
                                       wantCover=False,
                                       dangerRatio=0.0,
                                       meterColor=Vec4(0.11328125, 0.09375,
                                                       0.05078125, 1.0),
                                       baseColor=Vec4(1.0, 0.0, 0.0, 1.0))
            self.skillRing.setScale(0.5)
            self.skillRing.setR(180)
            self.skillRing.update(0.0, 1.0)
            foreGround.reparentTo(model)
            foreGround.setY(-0.1)
            self.__createWaveText(model)
            self.__createWaveLabel(model)
            min = Point3()
            max = Point3()
            model.calcTightBounds(min, max)
            size = max - min
            model.setPos(-size[0] / 2.0, 0, -size[2] / 2.0)
        finally:
            if timer:
                timer.removeNode()
        return

    def __createWaveText(self, parent):
        self.waveNumberTxt = TextNode('WaveNumber')
        self.waveNumberTxt.setFont(PiratesGlobals.getInterfaceFont())
        self.waveNumberTxt.setTextColor(PiratesGuiGlobals.TextFG1)
        self.waveNumberTxt.setShadow(0.05, 0.05)
        self.waveNumberTxt.setAlign(TextNode.ACenter)
        waveTxtNode = parent.attachNewNode(self.waveNumberTxt)
        waveTxtNode.setScale(0.12)
        waveTxtNode.setPos(0, -0.2, -0.08)
        waveTxtNode.setDepthTest(False)
        waveTxtNode.setDepthWrite(False)

    def __createWaveLabel(self, parent):
        self.waveLabelTxt = TextNode('WaveLabel')
        self.waveLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
        self.waveLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
        self.waveLabelTxt.setShadow(0.05, 0.05)
        self.waveLabelTxt.setAlign(TextNode.ACenter)
        self.waveLabelTxt.setText(PLocalizer.CannonDefense['WaveLabel'])
        waveLblNode = parent.attachNewNode(self.waveLabelTxt)
        waveLblNode.setScale(0.06)
        waveLblNode.setPos(0, -0.2, 0.015)
        waveLblNode.setDepthTest(False)
        waveLblNode.setDepthWrite(False)

    def destroy(self):
        self.timeRemaining.removeNode()

    def hide(self):
        self.timeRemaining.hide()

    def show(self):
        self.timeRemaining.show()

    def setPercent(self, percent):
        if percent < 0.0:
            percent = 0.0
        else:
            if percent > 1.0:
                percent = 1.0
        self.skillRing.update(percent, 1.0)

    def setWaveNumber(self, num):
        self.waveNumberTxt.setText(str(num))
示例#15
0
class BuffIcon(DirectFrame):
    Background = None
    Card = None

    def __init__(self, parent, effectId, duration, attackerId, **kw):
        optiondefs = (('relief', None, None), )
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, parent, **None)
        self.initialiseoptions(BuffIcon)
        if not self.Background:
            self.Background = loader.loadModel('models/gui/lookout_gui').find(
                '**/lookout_submit')
            self.Background.setScale(0.33000000000000002)

        if not self.Card:
            self.Card = loader.loadModel('models/textureCards/buff_icons')

        self.myIcon = None
        self.detailFrame = None
        self.dial = None
        self.iconScale = 0.070000000000000007
        self.effectId = effectId
        self.maxDuration = duration
        self.timeLeft = duration
        self.lastTimestamp = None
        self.attackerId = attackerId
        self.setDepthWrite(0)
        self.setFogOff()
        self.setLightOff()
        self.setBin('gui-fixed', 0)

    def makeIcons(self):
        self.Background.copyTo(self)
        self.dial = DialMeter(parent=self,
                              meterColor=Vec4(0.29999999999999999, 0.0,
                                              0.80000000000000004, 1),
                              baseColor=Vec4(0, 0, 0, 1),
                              scale=0.17000000000000001,
                              sortOrder=0)
        if self.effectId in buffTable:
            info = buffTable.get(self.effectId)
        else:
            info = buffTable.get(WeaponGlobals.C_UNKNOWN_EFFECT)
        self.myIcon = DirectButton(parent=self,
                                   relief=None,
                                   geom=self.Card.find('**/' + info[0]),
                                   geom_scale=self.iconScale,
                                   sortOrder=1)
        self.myIcon.bind(DGG.ENTER, self.showDetails)
        self.myIcon.bind(DGG.EXIT, self.hideDetails)
        self.updateIconInfo()

    def makeDetails(self):
        if self.detailFrame:
            return None

        normalScale = 0.97307200000000005
        parent = self.getParent()
        if parent:
            for i in range(0, 2):
                parent = parent.getParent()
                if not parent:
                    break
                    continue

        if parent:
            parentScale = parent.getScale()[0]
        else:
            parentScale = normalScale
        durationStr = str(int(self.maxDuration))
        if self.effectId in buffTable:
            text = buffTable[
                self.effectId][1] + PLocalizer.BuffDuration % durationStr
        else:
            text = buffTable[WeaponGlobals.C_UNKNOWN_EFFECT][
                1] + PLocalizer.BuffDuration % durationStr
        self.detailBox = DirectLabel(
            state=DGG.DISABLED,
            relief=None,
            text=text,
            text_align=TextNode.ALeft,
            text_scale=PiratesGuiGlobals.TextScaleExtraLarge * normalScale /
            parentScale,
            text_fg=(1, 1, 1, 1),
            text_wordwrap=15,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1)
        height = -(self.detailBox.getHeight() + 0.01)
        width = max(0.25, self.detailBox.getWidth() + 0.040000000000000001)
        self.detailFrame = BorderFrame(parent=self.myIcon,
                                       state=DGG.DISABLED,
                                       frameSize=(-0.040000000000000001, width,
                                                  height,
                                                  0.070000000000000007),
                                       pos=(0.050000000000000003, 0,
                                            -0.050000000000000003))
        self.detailBox.reparentTo(self.detailFrame)
        self.detailFrame.setBin('gui-popup', 0)
        self.detailFrame.hide()

    def showDetails(self, event):
        self.makeDetails()
        self.detailFrame.show()
        self.updateIconInfo()

    def hideDetails(self, event):
        if self.detailFrame:
            self.detailFrame.hide()

    def updateIconInfo(self):
        if self.lastTimestamp == None:
            timeOffset = 0.0
        else:
            timeOffset = globalClockDelta.localElapsedTime(self.lastTimestamp)
        duration = max(0.0, self.timeLeft - timeOffset)
        self.dial.update(duration, self.maxDuration)
        if self.detailFrame and not self.detailFrame.isHidden():
            if duration > 0:
                durationStr = PLocalizer.BuffDuration % str(int(duration) + 1)
            else:
                durationStr = ''
            if self.effectId in buffTable:
                text = buffTable[self.effectId][1] + durationStr
            else:
                text = buffTable[
                    WeaponGlobals.C_UNKNOWN_EFFECT][1] + durationStr
            self.detailBox['text'] = text

    def destroy(self):
        DirectFrame.destroy(self)
class CannonDefenseTimeRemainingUI:
    
    def __init__(self):
        self.timeRemaining = None
        self.skillRing = None
        self._loadAssets()

    
    def _loadAssets(self):
        timer = None
        
        try:
            timer = loader.loadModel('models/gui/pir_m_gui_can_timer')
            self.timeRemaining = base.a2dTopRight.attachNewNode('CannonDefenseTimeRemaining')
            self.timeRemaining.setDepthTest(True)
            self.timeRemaining.setDepthWrite(True)
            self.timeRemaining.setScale(0.75)
            model = self.timeRemaining.attachNewNode('model')
            foreGround = timer.find('**/timer')
            self.skillRing = DialMeter(model, wantCover = False, dangerRatio = 0.0, meterColor = Vec4(0.11328125, 0.09375, 0.05078125, 1.0), baseColor = Vec4(1.0, 0.0, 0.0, 1.0))
            self.skillRing.setScale(0.5)
            self.skillRing.setR(180)
            self.skillRing.update(0.0, 1.0)
            foreGround.reparentTo(model)
            foreGround.setY(-0.10000000000000001)
            self._CannonDefenseTimeRemainingUI__createWaveText(model)
            self._CannonDefenseTimeRemainingUI__createWaveLabel(model)
            min = Point3()
            max = Point3()
            model.calcTightBounds(min, max)
            size = max - min
            model.setPos(-size[0] / 2.0, 0, -size[2] / 2.0)
        finally:
            if timer:
                timer.removeNode()
            


    
    def _CannonDefenseTimeRemainingUI__createWaveText(self, parent):
        self.waveNumberTxt = TextNode('WaveNumber')
        self.waveNumberTxt.setFont(PiratesGlobals.getInterfaceFont())
        self.waveNumberTxt.setTextColor(PiratesGuiGlobals.TextFG1)
        self.waveNumberTxt.setShadow(0.050000000000000003, 0.050000000000000003)
        self.waveNumberTxt.setAlign(TextNode.ACenter)
        waveTxtNode = parent.attachNewNode(self.waveNumberTxt)
        waveTxtNode.setScale(0.12)
        waveTxtNode.setPos(0, -0.20000000000000001, -0.080000000000000002)
        waveTxtNode.setDepthTest(False)
        waveTxtNode.setDepthWrite(False)

    
    def _CannonDefenseTimeRemainingUI__createWaveLabel(self, parent):
        self.waveLabelTxt = TextNode('WaveLabel')
        self.waveLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
        self.waveLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
        self.waveLabelTxt.setShadow(0.050000000000000003, 0.050000000000000003)
        self.waveLabelTxt.setAlign(TextNode.ACenter)
        self.waveLabelTxt.setText(PLocalizer.CannonDefense['WaveLabel'])
        waveLblNode = parent.attachNewNode(self.waveLabelTxt)
        waveLblNode.setScale(0.059999999999999998)
        waveLblNode.setPos(0, -0.20000000000000001, 0.014999999999999999)
        waveLblNode.setDepthTest(False)
        waveLblNode.setDepthWrite(False)

    
    def destroy(self):
        self.timeRemaining.removeNode()

    
    def hide(self):
        self.timeRemaining.hide()

    
    def show(self):
        self.timeRemaining.show()

    
    def setPercent(self, percent):
        if percent < 0.0:
            percent = 0.0
        elif percent > 1.0:
            percent = 1.0
        
        self.skillRing.update(percent, 1.0)

    
    def setWaveNumber(self, num):
        self.waveNumberTxt.setText(str(num))
示例#17
0
class ReputationMeterDial(DirectFrame):
    
    def __init__(self, category, width = 0.40000000000000002):
        DirectFrame.__init__(self, state = DGG.DISABLED, relief = None)
        self.initialiseoptions(ReputationMeterDial)
        self.category = category
        self.level = 0
        self.value = 0
        self.max = 0
        self.masteredIval = None
        name = self.getCategoryName()
        self.changeMeter = ChangeDialMeter(parent = self, meterColor = VBase4(0.69999999999999996, 0.0, 0.0, 1), meterColor2 = VBase4(0.69999999999999996, 0.69999999999999996, 0.0, 1), baseColor = VBase4(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 1), wantCover = 0, scale = 0.45000000000000001)
        self.changeMeter.hide()
        self.meter = DialMeter(parent = self, meterColor = VBase4(0.69999999999999996, 0.0, 0.0, 1), baseColor = VBase4(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 1), wantCover = 0, scale = 0.45000000000000001)
        self.meter.setBackwards()
        self.lastLevel = None
        self.lastExp = None
        self.mastered = False
        self.categoryLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = name, text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0, 0, 0), textMayChange = 1)
        self.levelLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = '', text_scale = 0.080000000000000002, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_font = PiratesGlobals.getPirateFont(), pos = (-0.014999999999999999, 0, -0.080000000000000002), textMayChange = 1)
        logoModel = loader.loadModel('models/gui/potcLogo')
        guiModel = loader.loadModel('models/gui/toplevel_gui')
        self.valueLabel = DirectLabel(parent = self, state = DGG.DISABLED, relief = None, text = '', text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0.0, 0, -0.20000000000000001), textMayChange = 1)
        self.levelCapScroll = DirectFrame(parent = self, relief = None, image = guiModel.find('**/main_gui_quest_scroll'), image_scale = (0.13, 1.0, 0.089999999999999997), pos = (0.0, 0.0, -0.16250000000000001))
        self.levelCapScroll.hide()
        self.levelCapIcon = DirectFrame(parent = self, relief = None, image = logoModel.find('**/skull'), image_pos = (0.0, 0.0, 0.0), image_scale = 0.90000000000000002, pos = (-0.0275, 0.0, -0.105))
        self.levelCapIcon.hide()
        self.levelCapScroll.setTransparency(1)
        self.levelCapIcon.setTransparency(1)
        self.valueLabel.setTransparency(1)

    
    def destroy(self):
        DirectFrame.destroy(self)
        if self.masteredIval:
            self.masteredIval.pause()
            self.masteredIval = None
        

    
    def hideMasterOrnament(self):
        self.levelCapScroll.hide()
        self.levelCapIcon.hide()
        self.levelLabel.show()

    
    def showMasterOrnament(self):
        self.levelCapScroll.show()
        self.levelCapIcon.show()
        self.levelLabel.hide()
        self.mastered = True

    
    def masteredFX(self):
        if self.masteredIval:
            self.masteredIval.start()
            return None
        
        startColor = Vec4(1.0, 1.0, 1.0, 0.0)
        endColor = Vec4(1.0, 1.0, 1.0, 1.0)
        duration = 1.5
        fade = Parallel(LerpColorScaleInterval(self.levelCapScroll, duration, endColor, startColor, blendType = 'easeInOut'), LerpColorScaleInterval(self.levelCapIcon, duration, endColor, startColor, blendType = 'easeInOut'), LerpColorScaleInterval(self.valueLabel, duration, endColor, startColor, blendType = 'easeInOut'))
        startScale = Vec3(0.75, 0.75, 0.75)
        endScale = Vec3(1.0, 1.0, 1.0)
        duration = 1.0
        scale = Parallel(LerpScaleInterval(self.levelCapScroll, duration, endScale, startScale, blendType = 'easeInOut'), LerpScaleInterval(self.levelCapIcon, duration, endScale, startScale * 0.10000000000000001, blendType = 'easeInOut'), LerpScaleInterval(self.valueLabel, duration, endScale, startScale, blendType = 'easeInOut'))
        self.masteredIval = Parallel(fade, scale)
        self.masteredIval.start()

    
    def update(self, value, updateLocal = 0):
        if self.mastered:
            return None
        
        self.value = value
        (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(self.category, value)
        self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level)
        self.levelLabel['text'] = '%s' % level
        if self.category == InventoryType.OverallRep:
            levelCap = ReputationGlobals.GlobalLevelCap
            if updateLocal and level != self.level:
                localAvatar.setLevel(level)
            
        else:
            levelCap = ReputationGlobals.LevelCap
        self.level = level
        if level == levelCap:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.valueLabel['text_scale'] = 0.042999999999999997
            self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level
            self.categoryLabel.hide()
            self.meter.meterFaceHalf1.hide()
            self.meter.meterFaceHalf2.hide()
            self.meter.meterFace.setColor(0.10000000000000001, 0.40000000000000002, 0.10000000000000001, 1.0)
            self.valueLabel.setZ(0.029999999999999999)
            self.showMasterOrnament()
            self.masteredFX()
        else:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.meter.show()
            self.categoryLabel.show()
            self.valueLabel['text'] = '%s / %s' % (leftoverValue, self.max)
            self.valueLabel['text_scale'] = PiratesGuiGlobals.TextScaleLarge
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG2
            self.valueLabel.setZ(0.0)
            self.meter.update(leftoverValue, self.max)
            self.hideMasterOrnament()
            if self.lastLevel == None:
                self.lastLevel = level
            
            if self.lastExp == None:
                if hasattr(base, 'localAvatar'):
                    self.lastExp = localAvatar.getInventory().getReputation(self.category)
                
            
            if self.lastExp:
                expChange = value - self.lastExp
                if expChange and localAvatar.getGameState() != 'Fishing':
                    localAvatar.guiMgr.gameGui.createExpAlert(expChange, 4.0, Vec3(-0.93000000000000005, 0.0, 0.75), Vec3(0.0, 0.0, 0.25))
                
            
            if self.lastLevel != level:
                self.lastLevel = level
                glowFrameColor = Vec4(0.69999999999999996, 0.0, 0.0, 1.0)
                glowLevelColor = Vec4(0.80000000000000004, 0.0, 0.0, 1.0)
                startFrameColor = self.meter.meterFace.getColor()
                startLevelColor = Vec4(0.90000000000000002, 0.80000000000000004, 0.63, 1.0)
                startFrameScale = self.meter.meterFace.getScale()
                startLevelScale = self.levelLabel.getScale()
                scale = Vec3(1.2, 1.2, 1.2)
                objFrame = self.meter.meterFace
                objLevel = self.levelLabel
                levelUpIval = Sequence(Func(self.meter.meterFaceHalf1.hide), Func(self.meter.meterFaceHalf2.hide), Parallel(LerpColorInterval(objFrame, 3.0, startFrameColor, glowFrameColor, blendType = 'easeInOut'), LerpColorInterval(objLevel, 3.0, startLevelColor, glowLevelColor, blendType = 'easeInOut'), Sequence(LerpScaleInterval(objLevel, 0.25, scale, startFrameScale, blendType = 'easeInOut'), LerpScaleInterval(objLevel, 2.0, startFrameScale, blendType = 'easeInOut'))), Func(self.meter.meterFaceHalf1.show), Func(self.meter.meterFaceHalf2.show), Func(objLevel.clearColor))
                levelUpIval.start()
            elif self.lastExp is not None:
                if self.lastExp == value:
                    return None
                
            
            self.lastExp = value
            glowFrameColor = Vec4(1.0, 0, 0, 1.0)
            startFrameColorA = self.meter.meterFaceHalf1.getColor()
            startFrameColorB = self.meter.meterFaceHalf2.getColor()
            objFrameA = self.meter.meterFaceHalf1
            objFrameB = self.meter.meterFaceHalf2
            objFrameC = self.meter.meterFace
            if leftoverValue and float(self.max) / float(leftoverValue) > 2.0:
                expUpIval = Sequence(LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut'), Wait(0.20000000000000001), LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut'), Wait(0.10000000000000001), LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut'))
            else:
                expUpIval = Sequence(Parallel(LerpColorScaleInterval(objFrameA, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.20000000000000001, glowFrameColor, blendType = 'easeInOut')), Wait(0.20000000000000001), Parallel(LerpColorScaleInterval(objFrameA, 0.5, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.5, startFrameColorA, blendType = 'easeInOut')), Parallel(LerpColorScaleInterval(objFrameA, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.10000000000000001, glowFrameColor, blendType = 'easeInOut')), Wait(0.10000000000000001), Parallel(LerpColorScaleInterval(objFrameA, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut'), LerpColorScaleInterval(objFrameB, 0.29999999999999999, startFrameColorA, blendType = 'easeInOut')))
            expUpIval.start()

    
    def updateChange(self, value, newValue):
        self.value = value
        (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(self.category, value + newValue)
        self.max = ReputationGlobals.getReputationNeededToLevel(self.category, level)
        self.levelLabel['text'] = '%s' % level
        oldValue = leftoverValue - newValue
        if oldValue < 0:
            oldValue = 0
        
        if self.category == InventoryType.OverallRep:
            levelCap = ReputationGlobals.GlobalLevelCap
        else:
            levelCap = ReputationGlobals.LevelCap
        if level == levelCap:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG4
            self.valueLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.valueLabel['text_scale'] = 0.042999999999999997
            self.valueLabel['text'] = PLocalizer.RepCapText_Overall % level
            self.categoryLabel.hide()
            self.meter.meterFaceHalf1.hide()
            self.meter.meterFaceHalf2.hide()
            self.meter.meterFace.setColor(0.10000000000000001, 0.40000000000000002, 0.10000000000000001, 1.0)
            self.valueLabel.setZ(0.029999999999999999)
            self.showMasterOrnament()
            self.masteredFX()
        else:
            self.levelLabel['text_fg'] = PiratesGuiGlobals.TextFG1
            self.categoryLabel.show()
            self.valueLabel.hide()
            self.changeMeter.update(oldValue, leftoverValue, self.max)
            self.changeMeter.show()
            self.meter.hide()
            self.hideMasterOrnament()

    
    def setCategory(self, category):
        self.category = category
        name = self.getCategoryName()
        self.categoryLabel['text'] = name

    
    def getCategory(self):
        return self.category

    
    def getCategoryName(self):
        return PLocalizer.InventoryTypeNames[self.category]