Exemplo n.º 1
0
class DeltaContainer(ButtonIcon):
    __guid__ = 'uicls.DeltaContainer'
    default_height = 24

    def ApplyAttributes(self, attributes):
        ButtonIcon.ApplyAttributes(self, attributes)
        delta = attributes.delta
        self.deltaText = Label(parent=self, align=uiconst.CENTER, fontsize=9, top=2)
        self.UpdateDelta(delta)

    def ConstructIcon(self):
        self.icon = GlowSprite(name='icon', parent=self, align=uiconst.CENTERTOP, width=self.iconSize, height=self.iconSize, texturePath=self.texturePath, state=uiconst.UI_DISABLED, color=self.iconColor, rotation=self.rotation)

    def UpdateDelta(self, delta):
        deltaText = self.GetDeltaText(delta)
        if delta > 0:
            self.deltaText.text = deltaText
            self.deltaText.align = uiconst.CENTERBOTTOM
            self.icon.align = uiconst.CENTERTOP
            texturePath = 'res:/UI/Texture/classes/MultiSell/up.png'
        elif delta < 0:
            self.deltaText.text = deltaText
            self.deltaText.align = uiconst.CENTERTOP
            self.icon.align = uiconst.CENTERBOTTOM
            texturePath = 'res:/UI/Texture/classes/MultiSell/down.png'
        else:
            self.icon.align = uiconst.CENTER
            self.deltaText.text = ''
            texturePath = 'res:/UI/Texture/classes/MultiSell/equal.png'
        self.icon.SetTexturePath(texturePath)

    def GetDeltaText(self, delta):
        if delta < 0:
            color = '<color=0xffff5050>'
        else:
            color = '<color=0xff00ff00>'
        if abs(delta) < 1.0:
            showFraction = 1
        else:
            showFraction = 0
        deltaText = '%s%s</color>' % (color, GetByLabel('UI/Common/Percentage', percentage=FmtAmt(delta * 100, showFraction=showFraction)))
        return deltaText
Exemplo n.º 2
0
class ButtonBase(uiprimitives.Container):
    """
    An abstract button that others inherit from
    """
    __guid__ = 'neocom.ButtonBase'
    __notifyevents__ = ['ProcessNeocomBlinkPulse']
    default_name = 'ButtonBase'
    default_state = uiconst.UI_NORMAL
    default_align = uiconst.TOPLEFT
    default_isDraggable = True
    PADHORIZONTAL = 6
    PADVERTICAL = 4
    ACTIVEFILL_DEFAULTALPHA = 0.5
    ACTIVEFILL_HOVERALPHA = 0.8

    def ApplyAttributes(self, attributes):
        uiprimitives.Container.ApplyAttributes(self, attributes)
        self.btnData = attributes.btnData
        self.btnNum = attributes.btnNum
        self.width = attributes.width
        self._isDraggable = attributes.get('isDraggable',
                                           self.default_isDraggable)
        self._openNeocomPanel = None
        self.height = self.width
        self.top = self.height * self.btnNum
        self.panel = None
        self.blinkThread = None
        self.realTop = self.top
        self.dragEventCookie = None
        self.disableClick = False
        self.iconSize = self.height - 2 * self.PADVERTICAL
        self.iconTransform = uiprimitives.Transform(name='iconTransform',
                                                    parent=self,
                                                    align=uiconst.TOALL,
                                                    scalingCenter=(0.5, 0.5))
        self.iconLabelCont = None
        if self.btnData.id == 'map_beta':
            Sprite(parent=self.iconTransform,
                   align=uiconst.TOPLEFT,
                   pos=(0, 0, 11, 29),
                   texturePath='res:/UI/Texture/Shared/betaTag.png',
                   state=uiconst.UI_DISABLED)
        self.icon = GlowSprite(parent=self.iconTransform,
                               name='icon',
                               state=uiconst.UI_DISABLED,
                               align=uiconst.CENTER,
                               width=self.iconSize,
                               height=self.iconSize,
                               iconOpacity=1.0)
        self.UpdateIcon()
        PAD = 1
        self.blinkSprite = SpriteThemeColored(
            bgParent=self,
            name='blinkSprite',
            texturePath='res:/UI/Texture/classes/Neocom/buttonBlink.png',
            state=uiconst.UI_HIDDEN,
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
        self.activeFrame = FrameThemeColored(
            bgParent=self,
            name='hoverFill',
            texturePath='res:/UI/Texture/classes/Neocom/buttonActive.png',
            cornerSize=5,
            state=uiconst.UI_HIDDEN,
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
        self.CheckIfActive()
        self.dropFrame = uicontrols.Frame(parent=self,
                                          name='hoverFrame',
                                          color=util.Color.GetGrayRGBA(
                                              1.0, 0.5),
                                          state=uiconst.UI_HIDDEN)
        sm.RegisterNotify(self)

    def UpdateIcon(self):
        texturePath = self._GetPathFromIconNum(self.btnData.iconPath)
        self.icon.SetTexturePath(texturePath)

    def CheckIfActive(self):
        if self.btnData.isActive:
            self.activeFrame.Show()
        else:
            self.activeFrame.Hide()

    def GetIconPath(self):
        return self._GetPathFromIconNum(self.btnData.iconPath)

    def _GetPathFromIconNum(self, iconNum):
        if iconNum.startswith('res:/'):
            return iconNum
        parts = iconNum.split('_')
        if len(parts) == 2:
            sheet, iconNum = parts
            iconSize = uix.GetIconSize(sheet)
            return 'res:/ui/texture/icons/%s_%s_%s.png' % (
                int(sheet), int(iconSize), int(iconNum))
        elif len(parts) == 4:
            root, sheet, iconSize, iconNum = parts
            if root == 'ui':
                root = 'icons'
            return 'res:/ui/texture/%s/%s_%s_%s.png' % (
                root, int(sheet), int(iconSize), int(iconNum))
        else:
            return neocomCommon.ICONPATH_DEFAULT

    def IsDraggable(self):
        return self._isDraggable

    def SetDraggable(self, isDraggable):
        self._isDraggable = isDraggable

    def GetMenu(self):
        return self.btnData.GetMenu()

    def LoadTooltipPanel(self, tooltipPanel, *args):
        isOpen = self._openNeocomPanel and not self._openNeocomPanel.destroyed
        if isOpen:
            return
        tooltipPanel.LoadGeneric3ColumnTemplate()
        blinkHintStr = None
        if getattr(self.btnData, 'cmdName', None):
            cmd = uicore.cmd.commandMap.GetCommandByName(self.btnData.cmdName)
            tooltipPanel.AddCommandTooltip(cmd)
            blinkHintStr = self.btnData.blinkHint
        else:
            label = None
            if self.IsSingleWindow():
                wnd = self.GetWindow()
                if not wnd.destroyed:
                    label = wnd.GetCaption()
            elif self.btnData.children:
                label = self.btnData.children[0].wnd.GetNeocomGroupLabel()
            mainStr = label or self.btnData.label
            tooltipPanel.AddLabelMedium(text=mainStr)
        self.LoadTooltipPanelDetails(tooltipPanel, self.btnData)
        if blinkHintStr:
            tooltipPanel.AddLabelMedium(text=blinkHintStr,
                                        width=200,
                                        colSpan=tooltipPanel.columns)

    def LoadTooltipPanelDetails(cls, tooltipPanel, btnData):
        if btnData.id == 'wallet':
            showFractions = settings.char.ui.Get('walletShowCents', False)
            personalWealth = util.FmtISK(
                sm.GetService('wallet').GetWealth(), showFractions)
            tooltipPanel.AddLabelValue(
                label=localization.GetByLabel('Tooltips/Neocom/Balance'),
                value=personalWealth)
            canAccess = sm.GetService(
                'wallet').HaveReadAccessToCorpWalletDivision(
                    session.corpAccountKey)
            if canAccess:
                corpWealth = util.FmtISK(
                    sm.GetService('wallet').GetCorpWealthCached1Min(
                        session.corpAccountKey), showFractions)
                tooltipPanel.AddLabelValue(label=localization.GetByLabel(
                    'Tooltips/Neocom/CorporationBalance'),
                                           value=corpWealth)

    def GetTooltipPointer(self):
        return uiconst.POINT_LEFT_2

    def IsSingleWindow(self):
        return False

    def OnMouseEnter(self, *args):
        self.btnData.SetBlinkingOff()
        self.icon.OnMouseEnter()

    def OnMouseExit(self, *args):
        self.icon.OnMouseExit()

    def OnMouseDown(self, *args):
        if not self.IsDraggable():
            return
        if not uicore.uilib.leftbtn:
            return
        self.isDragging = False
        self.mouseDownY = uicore.uilib.y
        if self.dragEventCookie is not None:
            uicore.event.UnregisterForTriuiEvents(self.dragEventCookie)
        self.dragEventCookie = uicore.event.RegisterForTriuiEvents(
            uiconst.UI_MOUSEMOVE, self.OnDrag)
        uicore.animations.Tr2DScaleTo(self.iconTransform,
                                      self.iconTransform.scale, (0.95, 0.95),
                                      duration=0.1)
        self.icon.OnMouseDown()

    def OnMouseUp(self, *args):
        if uicore.uilib.mouseOver == self:
            uicore.animations.Tr2DScaleTo(self.iconTransform,
                                          self.iconTransform.scale, (1.0, 1.0),
                                          duration=0.1)
        if self.dragEventCookie is not None:
            uicore.event.UnregisterForTriuiEvents(self.dragEventCookie)
            self.dragEventCookie = None
        self.icon.OnMouseUp()

    def OnDragEnd(self, *args):
        uicore.event.UnregisterForTriuiEvents(self.dragEventCookie)
        self.dragEventCookie = None
        self.isDragging = False
        sm.GetService('neocom').OnButtonDragEnd(self)
        self.CheckIfActive()

    def OnDrag(self, *args):
        if math.fabs(self.mouseDownY - uicore.uilib.y) > 5 or self.isDragging:
            if not self.isDragging:
                uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEUP,
                                                    self.OnDragEnd)
            self.disableClick = True
            self.isDragging = True
            sm.GetService('neocom').OnButtonDragged(self)
        return True

    def OnClick(self, *args):
        if not self or self.destroyed:
            return
        self.btnData.CheckContinueBlinking()
        if not self.disableClick:
            self.OnClickCommand()
        if not self or self.destroyed:
            return
        self.disableClick = False
        if self.dragEventCookie:
            uicore.event.UnregisterForTriuiEvents(self.dragEventCookie)

    def OnDblClick(self, *args):
        """ Swallow double click event so that we don't get two OnClick events """
        pass

    def OnClickCommand(self):
        """
        Overridden by subclasses
        """
        pass

    def OnSwitched(self):
        uicore.effect.MorphUIMassSpringDamper(item=self,
                                              attrname='opacity',
                                              float=1,
                                              newVal=1.0,
                                              minVal=0,
                                              maxVal=2.0,
                                              dampRatio=0.45,
                                              frequency=15.0,
                                              initSpeed=0,
                                              maxTime=4.0,
                                              callback=None,
                                              initVal=0.0)
        self.isDragging = False
        self.disableClick = False

    def GetDragData(self, *args):
        if self.btnData.isDraggable:
            return [self.btnData]

    def BlinkOnce(self, duration=0.7):
        self.blinkSprite.Show()
        uicore.animations.SpSwoopBlink(self.blinkSprite,
                                       rotation=math.pi * 0.75,
                                       duration=duration)

    def ProcessNeocomBlinkPulse(self):
        if self.btnData.isBlinking:
            self.BlinkOnce()

    def OnDropData(self, source, dropData):
        if not sm.GetService('neocom').IsValidDropData(dropData):
            return
        index = self.btnData.parent.children.index(self.btnData)
        sm.GetService('neocom').OnBtnDataDropped(dropData[0], index)

    def OnDragEnter(self, panelEntry, dropData):
        if not sm.GetService('neocom').IsValidDropData(dropData):
            return
        sm.GetService('neocom').OnButtonDragEnter(self.btnData, dropData[0])
        uthread.new(self.ShowPanelOnMouseHoverThread)

    def OnDragExit(self, *args):
        sm.GetService('neocom').OnButtonDragExit(self.btnData, args)

    def ToggleNeocomPanel(self):
        isOpen = self._openNeocomPanel and not self._openNeocomPanel.destroyed
        sm.GetService('neocom').CloseAllPanels()
        if isOpen:
            self._openNeocomPanel = None
        else:
            self._openNeocomPanel = sm.GetService('neocom').ShowPanel(
                triggerCont=self,
                panelClass=self.GetPanelClass(),
                panelAlign=neocomCommon.PANEL_SHOWONSIDE,
                parent=uicore.layer.abovemain,
                btnData=self.btnData)
        RefreshTooltipForOwner(self)

    def ShowPanelOnMouseHoverThread(self):
        if len(self.btnData.children) <= 1:
            return
        blue.pyos.synchro.Sleep(500)
        if not self or self.destroyed:
            return
        if uicore.uilib.mouseOver == self:
            self.ToggleNeocomPanel()

    def GetPanelClass(self):
        return neocomPanels.PanelGroup

    def SetAsActive(self):
        self.btnData.isActive = True
        self.activeFrame.state = uiconst.UI_DISABLED

    def SetAsInactive(self):
        self.btnData.isActive = False
        self.activeFrame.state = uiconst.UI_HIDDEN
class AchievementTreeSlot(Container):
    default_align = uiconst.TOPLEFT
    default_state = uiconst.UI_NORMAL
    default_pickRadius = -1
    nameLabel = None
    tooltipPanel = None
    localScale = 1.0

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.achievementGroupID = attributes.achievementGroupID
        self.hexGridPosition = attributes.hexGridPosition
        self.nameLabel = InfoPanelLabel(parent=self.parent,
                                        state=uiconst.UI_DISABLED,
                                        align=uiconst.TOPLEFT,
                                        idx=0)
        self.stateSprite = GlowSprite(parent=self,
                                      pos=(0, 0, 20, 20),
                                      align=uiconst.CENTER,
                                      state=uiconst.UI_DISABLED)
        self.activeEffectSprite = SpriteThemeColored(
            parent=self,
            state=uiconst.UI_DISABLED,
            spriteEffect=trinity.TR2_SFX_MODULATE,
            blendMode=trinity.TR2_SBM_ADDX2,
            texturePath='res:/UI/Texture/classes/Achievements/hexPingGlow.png',
            textureSecondaryPath=
            'res:/UI/Texture/classes/Achievements/hexPingMask.png',
            pos=(0, 0, 300, 300),
            align=uiconst.CENTER,
            opacity=0.0)
        self.activeStateSprite = SpriteThemeColored(
            parent=self,
            state=uiconst.UI_DISABLED,
            texturePath='res:/UI/Texture/classes/Achievements/hexActive.png',
            pos=(0, 0, 200, 200),
            align=uiconst.CENTER,
            opacity=0.0,
            blendMode=trinity.TR2_SBM_ADDX2,
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
        self.backgroundSprite = SpriteThemeColored(
            bgParent=self,
            texturePath=
            'res:/UI/Texture/classes/Achievements/hexBackIncomplete.png',
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
            opacity=0.5)
        self.UpdateGroupState()

    def Close(self, *args, **kwds):
        if self.nameLabel and not self.nameLabel.destroyed:
            self.nameLabel.LoadTooltipPanel = None
            self.nameLabel.GetTooltipPosition = None
        return Container.Close(self, *args, **kwds)

    def GetTooltipPosition(self, *args, **kwds):
        return self.GetAbsolute()

    def UpdateGroupState(self):
        activeGroupID = sm.GetService(
            'achievementSvc').GetActiveAchievementGroupID()
        groupData = GetAchievementGroup(self.achievementGroupID)
        totalNum = len(groupData.GetAchievementTasks())
        completed = len(
            [x for x in groupData.GetAchievementTasks() if x.completed])
        if totalNum == completed:
            self.stateSprite.SetTexturePath(
                'res:/UI/Texture/classes/Achievements/iconComplete.png')
            self.progressState = STATE_COMPLETED
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackComplete.png'
        elif completed:
            if activeGroupID == self.achievementGroupID:
                self.stateSprite.SetTexturePath(
                    'res:/UI/Texture/classes/Achievements/iconPartialActive.png'
                )
            else:
                self.stateSprite.SetTexturePath(
                    'res:/UI/Texture/classes/Achievements/iconPartial.png')
            self.progressState = STATE_INPROGRESS
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackComplete.png'
        else:
            if activeGroupID == self.achievementGroupID:
                self.stateSprite.SetTexturePath(
                    'res:/UI/Texture/classes/Achievements/iconIncompleteActive.png'
                )
            else:
                self.stateSprite.SetTexturePath(
                    'res:/UI/Texture/classes/Achievements/iconIncomplete.png')
            self.progressState = STATE_INCOMPLETE
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackIncomplete.png'
        self.nameLabel.text = groupData.groupName
        if activeGroupID == self.achievementGroupID:
            self.activeEffectSprite.display = True
            self.activeStateSprite.display = True
            uicore.animations.FadeTo(self.activeEffectSprite,
                                     startVal=0.7,
                                     endVal=0.2,
                                     duration=0.5)
            r, g, b, a = sm.GetService('uiColor').GetUIColor(
                uiconst.COLORTYPE_UIHILIGHT)
            uicore.animations.MorphVector2(self.activeEffectSprite,
                                           'scale',
                                           startVal=(2.5, 2.5),
                                           endVal=(0.0, 0.0),
                                           duration=0.33)
            uicore.animations.SpColorMorphTo(self.activeStateSprite,
                                             startColor=(0, 0, 0, 0),
                                             endColor=(r, g, b, 1.0),
                                             duration=0.3,
                                             curveType=uiconst.ANIM_OVERSHOT,
                                             callback=self.PulseActive)
        else:
            uicore.animations.FadeOut(self.activeStateSprite, duration=0.125)
            uicore.animations.FadeOut(self.activeEffectSprite, duration=0.125)
        if self.tooltipPanel:
            tooltipPanel = self.tooltipPanel()
            if tooltipPanel and not tooltipPanel.destroyed:
                tooltipPanel.Flush()
                self.LoadTooltipPanel(tooltipPanel)

    def PulseActive(self):
        r, g, b, a = sm.GetService('uiColor').GetUIColor(
            uiconst.COLORTYPE_UIHILIGHT)
        uicore.animations.SpColorMorphTo(self.activeStateSprite,
                                         startColor=(r, g, b, 1.0),
                                         endColor=(r * 0.8, g * 0.8, b * 0.8,
                                                   1.0),
                                         duration=1.5,
                                         curveType=uiconst.ANIM_WAVE,
                                         loops=uiconst.ANIM_REPEAT)

    def UpdateLabelPosition(self):
        if not self.nameLabel:
            return
        if self.localScale < 1.0:
            self.nameLabel.fontsize = fontConst.EVE_MEDIUM_FONTSIZE
        else:
            self.nameLabel.fontsize = fontConst.EVE_LARGE_FONTSIZE
        self.nameLabel.left = self.left + self.width / 2 + 14
        self.nameLabel.top = self.top + (self.height -
                                         self.nameLabel.textheight) / 2

    def SetLocalScale(self, localScale):
        self.localScale = localScale
        self.activeEffectSprite.width = self.activeEffectSprite.height = 300 * localScale
        self.activeStateSprite.width = self.activeStateSprite.height = 200 * localScale

    def OnClick(self, *args):
        sm.GetService('achievementSvc').SetActiveAchievementGroupID(
            self.achievementGroupID)

    def OnMouseEnter(self, *args):
        uicore.animations.FadeTo(self.backgroundSprite,
                                 startVal=self.backgroundSprite.opacity,
                                 endVal=1.0,
                                 duration=0.2,
                                 curveType=uiconst.ANIM_OVERSHOT)
        self.moTimer = AutoTimer(10, self.CheckMouseOver)
        if not SLOT_SHOW_MOUSEOVER_INFO:
            self.mouseEnterDelay = AutoTimer(100, self.CheckMouseEnter)

    def CheckMouseEnter(self, *args):
        self.mouseEnterDelay = None
        if uicore.uilib.mouseOver is self:
            sm.ScatterEvent('OnAchievementTreeMouseOver',
                            self.achievementGroupID)

    def CheckMouseOver(self):
        if uicore.uilib.mouseOver is self:
            return
        if uicore.uilib.mouseOver.IsUnder(self):
            return
        if self.nameLabel and uicore.uilib.mouseOver is self.nameLabel:
            return
        self.moTimer = None
        uicore.animations.FadeTo(self.backgroundSprite,
                                 startVal=self.backgroundSprite.opacity,
                                 endVal=0.5,
                                 duration=0.1)

    def GetBounds(self):
        return (self.left, self.top, self.left + self.width,
                self.top + self.height)

    def LoadTooltipPanel(self, tooltipPanel, *args, **kwds):
        if not SLOT_SHOW_MOUSEOVER_INFO:
            return
        tooltipPanel.columns = 1
        tooltipPanel.margin = (10, 5, 10, 3)
        tooltipPanel.state = uiconst.UI_NORMAL
        groupData = GetAchievementGroup(self.achievementGroupID)
        if groupData:
            AchievementGroupEntry(parent=tooltipPanel,
                                  groupInfo=groupData,
                                  align=uiconst.TOPLEFT,
                                  width=240)

    def GetTooltipPosition(self, *args):
        return self.GetAbsolute()

    def GetTooltipPositionFallbacks(self, *args):
        return []

    def GetTooltipPointer(self, *args):
        return uiconst.POINT_TOP_2

    @apply
    def pos():
        fget = Container.pos.fget

        def fset(self, value):
            Container.pos.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())

    @apply
    def left():
        fget = Container.left.fget

        def fset(self, value):
            Container.left.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())

    @apply
    def top():
        fget = Container.top.fget

        def fset(self, value):
            Container.top.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())
Exemplo n.º 4
0
class ButtonIcon(Container):
    __guid__ = 'uicontrols.ButtonIcon'
    OPACITY_IDLE = 0.0
    OPACITY_INACTIVE = 0.0
    OPACITY_MOUSEHOVER = 1.1
    OPACITY_MOUSECLICK = 2.5
    OPACITY_SELECTED = 0.5
    COLOR_DEFAULT = (1, 1, 1, 1.0)
    OPACITY_GLOW_IDLE = 0.0
    OPACITY_GLOW_MOUSEHOVER = 0.3
    OPACITY_GLOW_MOUSECLICK = 0.6
    default_func = None
    default_args = None
    default_width = 32
    default_height = 32
    default_align = uiconst.TOPLEFT
    default_state = uiconst.UI_NORMAL
    default_texturePath = None
    default_isActive = True
    default_iconSize = 16
    default_rotation = 0
    default_noBgSize = 1
    default_iconColor = None
    default_colorSelected = None
    default_isHoverBGUsed = None
    default_isSelectedBgUsed = False
    default_hoverTexture = None
    default_downTexture = None
    default_showGlow = True

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.func = attributes.get('func', self.default_func)
        self.args = attributes.get('args', self.default_args)
        self.isActive = attributes.get('isActive', True)
        self.texturePath = attributes.get('texturePath',
                                          self.default_texturePath)
        self.iconSize = attributes.get('iconSize', self.default_iconSize)
        self.iconColor = attributes.get('iconColor', self.default_iconColor)
        self.isHoverBGUsed = attributes.Get('isHoverBGUsed',
                                            self.default_isHoverBGUsed)
        self.isSelectedBgUsed = attributes.Get('isSelectedBgUsed',
                                               self.default_isSelectedBgUsed)
        self.colorSelected = attributes.Get('colorSelected',
                                            self.default_colorSelected)
        self.rotation = attributes.Get('rotation', self.default_rotation)
        self.hoverTexture = attributes.Get('hoverTexture',
                                           self.default_hoverTexture)
        self.downTexture = attributes.Get('downTexture',
                                          self.default_downTexture)
        self.showGlow = attributes.Get('showGlow', self.default_showGlow)
        if self.isHoverBGUsed is None:
            if self.iconSize < self.default_noBgSize:
                self.isHoverBGUsed = True
            else:
                self.isHoverBGUsed = False
        self.isSelected = False
        self.enabled = True
        self.ConstructIcon()
        self.glowIcon = None
        width, height = self.GetAbsoluteSize()
        size = min(width, height)
        bgCont = Container(name='bgCont',
                           parent=self,
                           align=uiconst.CENTER,
                           state=uiconst.UI_DISABLED,
                           width=size,
                           height=size)
        self.bgContainer = bgCont
        self.selectedBG = None
        self.ConstructBackground()
        if self.isSelectedBgUsed:
            self.ConstructSelectedBackground()
        self.blinkBg = None
        self.SetActive(self.isActive, animate=False)

    def ConstructBackground(self):
        self.mouseEnterBG = SpriteThemeColored(
            name='mouseEnterBG',
            bgParent=self.bgContainer,
            texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png',
            opacity=0.0,
            color=self.colorSelected)
        self.mouseDownBG = SpriteThemeColored(
            name='mouseEnterBG',
            bgParent=self.bgContainer,
            texturePath='res:/UI/Texture/classes/ButtonIcon/mouseDown.png',
            opacity=0.0,
            color=self.colorSelected)

    def ConstructIcon(self):
        self.icon = GlowSprite(name='icon',
                               parent=self,
                               align=uiconst.CENTER,
                               width=self.iconSize,
                               height=self.iconSize,
                               texturePath=self.texturePath,
                               state=uiconst.UI_DISABLED,
                               color=self.iconColor,
                               iconOpacity=0.5,
                               gradientStrength=0.5,
                               rotation=self.rotation)

    def SetTexturePath(self, texturePath):
        self.icon.SetTexturePath(texturePath)

    def SetColor(self, color):
        self.mouseEnterBG.SetFixedColor(color)
        self.mouseDownBG.SetFixedColor(color)

    def ConstructBlinkBackground(self):
        if self.blinkBg:
            return
        self.blinkBg = SpriteThemeColored(
            name='blinkBG',
            bgParent=self.bgContainer,
            texturePath='res:/UI/Texture/classes/ButtonIcon/mouseEnter.png',
            opacity=0.0)

    def ConstructSelectedBackground(self):
        if self.selectedBG:
            return
        self.selectedBG = FillThemeColored(
            name='selectedBG',
            bgParent=self.bgContainer,
            colorType=uiconst.COLORTYPE_UIHILIGHT,
            idx=0,
            color=self.colorSelected)
        self.UpdateSelectedColor()

    def AccessIcon(self):
        return self.icon

    def AccessBackground(self):
        return self.bgContainer

    def Disable(self, opacity=0.5):
        self.opacity = opacity
        self.enabled = 0
        if self.mouseEnterBG:
            self.mouseEnterBG.StopAnimations()
            self.mouseEnterBG.opacity = 0.0

    def Enable(self):
        self.opacity = 1.0
        self.enabled = 1

    def SetRotation(self, value):
        self.icon.SetRotation(value)

    def UpdateIconState(self, animate=True):
        texturePath = None
        if uicore.uilib.mouseOver == self:
            if uicore.uilib.leftbtn:
                glowAmount = self.OPACITY_MOUSECLICK
                texturePath = self.downTexture
            else:
                glowAmount = self.OPACITY_MOUSEHOVER
                texturePath = self.hoverTexture
        elif self.isActive:
            glowAmount = self.OPACITY_IDLE
            texturePath = self.texturePath
        else:
            glowAmount = self.OPACITY_INACTIVE
            texturePath = self.texturePath
        if isinstance(self.icon, GlowSprite):
            if self.downTexture:
                self.SetTexturePath(texturePath)
            if self.showGlow:
                if animate:
                    uicore.animations.MorphScalar(self.icon,
                                                  'glowAmount',
                                                  self.icon.glowAmount,
                                                  glowAmount,
                                                  duration=0.2)
                else:
                    self.icon.glowAmount = glowAmount

    def SetActive(self, isActive, animate=True):
        self.UpdateIconState(animate)

    @telemetry.ZONE_METHOD
    def SetSelected(self):
        if self.isSelected:
            return
        self.isSelected = True
        self.UpdateSelectedColor()
        self.UpdateIconState()

    @telemetry.ZONE_METHOD
    def SetDeselected(self):
        if not self.isSelected:
            return
        self.isSelected = False
        self.UpdateSelectedColor()
        self.UpdateIconState()

    def UpdateSelectedColor(self):
        if self.isSelected:
            if self.selectedBG:
                self.selectedBG.opacity = self.OPACITY_SELECTED
                iconColor = GetIconColor(self.colorSelected)
            else:
                iconColor = self.colorSelected
        else:
            if self.selectedBG:
                self.selectedBG.opacity = 0.0
            iconColor = self.COLOR_DEFAULT
        self.icon.SetRGBA(*iconColor)

    def Blink(self, duration=0.8, loops=1):
        self.ConstructBlinkBackground()
        uicore.animations.FadeTo(self.blinkBg,
                                 0.0,
                                 0.9,
                                 duration=duration,
                                 curveType=uiconst.ANIM_WAVE,
                                 loops=loops)

    def StopBlink(self):
        if self.blinkBg:
            uicore.animations.FadeOut(self.blinkBg, 0.3)

    def OnClick(self, *args):
        if not self.func or not self.enabled:
            return
        if audioConst.BTNCLICK_DEFAULT:
            uicore.Message(audioConst.BTNCLICK_DEFAULT)
        if type(self.args) == tuple:
            self.func(*self.args)
        elif self.args:
            self.func(self.args)
        else:
            self.func()

    def OnMouseEnter(self, *args):
        self.StopBlink()
        if not self.enabled:
            return
        self.UpdateIconState()
        if self.isHoverBGUsed:
            uicore.animations.FadeIn(self.mouseEnterBG, 0.5, duration=0.2)

    def OnMouseExit(self, *args):
        self.SetActive(self.isActive)
        self.UpdateIconState()
        if self.isHoverBGUsed:
            uicore.animations.FadeOut(self.mouseEnterBG, duration=0.2)

    def OnMouseDown(self, *args):
        if not self.enabled:
            return
        self.SetActive(self.isActive)
        if self.isHoverBGUsed:
            uicore.animations.FadeTo(self.mouseDownBG,
                                     self.mouseDownBG.opacity,
                                     1.0,
                                     duration=0.1)
            uicore.animations.FadeOut(self.mouseEnterBG, duration=0.1)
        self.UpdateIconState()

    def OnMouseUp(self, *args):
        if self.isHoverBGUsed:
            uicore.animations.FadeOut(self.mouseDownBG, duration=0.1)
        if not self.enabled:
            return
        self.UpdateIconState()
        if uicore.uilib.mouseOver == self:
            if self.isHoverBGUsed:
                uicore.animations.FadeIn(self.mouseEnterBG, 0.5, duration=0.1)

    def OnEndDrag(self, *args):
        if uicore.uilib.mouseOver != self:
            uicore.animations.FadeOut(self.mouseEnterBG, duration=0.2)
        elif self.isHoverBGUsed:
            uicore.animations.FadeIn(self.mouseEnterBG, duration=0.1)
        uicore.animations.FadeOut(self.mouseDownBG, duration=0.1)
class RadialMenuActionBase(uiprimitives.Transform):
    """
        this is the base for the buttons in the radial menu
    """
    __guid__ = 'uicls.RadialMenuActionBase'
    default_left = 0
    default_top = 0
    default_align = uiconst.CENTERTOP
    default_state = uiconst.UI_NORMAL
    moveOverSliceBasePath = 'res:/UI/Texture/classes/RadialMenu/mouseOver_%s.png'
    selelectedBasePath = 'res:/UI/Texture/classes/RadialMenu/selected_%s.png'
    emptySliceBasePath = 'res:/UI/Texture/classes/RadialMenu/emptySlice_%s.png'
    sliceBasePath = 'res:/UI/Texture/classes/RadialMenu/slice_%s.png'
    default_width = 100
    default_height = 70
    default_fullWidth = default_width
    default_fullHeight = default_height

    def ApplyAttributes(self, attributes):
        uiprimitives.Transform.ApplyAttributes(self, attributes)
        self.degree = attributes.get('degree', 0)
        self.func = None
        self.funcArgs = None
        self.itemID = attributes.itemID
        self.isDisabled = False
        self.degreeWidth = attributes.degreeWidth
        self.labelPath = ''
        self.labelText = ''
        self.isEmpty = attributes.get('isEmpty', False)
        self.commandName = None
        self.isHilighted = False
        self.fullWidth = attributes.sizeInfo.buttonWidth
        self.fullHeight = attributes.sizeInfo.buttonHeight
        iconPar = uiprimitives.Transform(parent=self,
                                         name='iconPar',
                                         pos=(0, 3, 32, 32),
                                         state=uiconst.UI_DISABLED,
                                         align=uiconst.CENTER)
        iconPar.rotation = mathUtil.DegToRad(self.degree)
        self.icon = GlowSprite(parent=iconPar,
                               name='icon',
                               pos=(0, 0, 32, 32),
                               state=uiconst.UI_DISABLED,
                               align=uiconst.CENTER)
        selectionSlice = SpriteUnderlay(parent=self,
                                        name='selectionSlice',
                                        state=uiconst.UI_DISABLED,
                                        texturePath=self.selelectedBasePath %
                                        self.degreeWidth,
                                        align=uiconst.TOALL,
                                        opacity=0.9)
        selectionSlice.display = False
        self.selectionSlice = selectionSlice
        if self.isEmpty:
            sliceTexturePath = self.emptySliceBasePath % self.degreeWidth
        else:
            sliceTexturePath = self.sliceBasePath % self.degreeWidth
        self.hilite = SpriteUnderlay(parent=self,
                                     name='hilite',
                                     state=uiconst.UI_DISABLED,
                                     texturePath=self.selelectedBasePath %
                                     self.degreeWidth,
                                     align=uiconst.TOALL,
                                     colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
                                     opacity=0.0)
        self.availableSlice = SpriteUnderlay(parent=self,
                                             name='availableSlice',
                                             state=uiconst.UI_DISABLED,
                                             texturePath=sliceTexturePath,
                                             align=uiconst.TOALL,
                                             opacity=attributes.get(
                                                 'buttonBackgroundOpacity',
                                                 0.8))
        self.unavailableSlice = SpriteUnderlay(
            parent=self,
            name='unavailableSlice',
            state=uiconst.UI_DISABLED,
            texturePath=sliceTexturePath,
            align=uiconst.TOALL,
            colorType=uiconst.COLORTYPE_UIBASE,
            opacity=0.85)
        self.unavailableSlice.display = False
        self.sliceInUse = self.availableSlice

    def SetButtonInfo(self,
                      labelPath,
                      labelArgs,
                      buttonInfo=None,
                      isEnabled=True,
                      iconTexturePath=None):
        self.labelPath = labelPath
        if isEnabled:
            self.labelText = localization.GetByLabel(labelPath, **labelArgs)
        else:
            self.labelText = ''
        self.name = 'actionButton_%s' % labelPath.split('/')[-1]
        if isEnabled:
            self.SetEnabled()
        else:
            self.SetDisabled()
        if iconTexturePath is not None:
            self.SetIcon(iconTexturePath)
        if buttonInfo is None:
            return
        buttonFunc = buttonInfo.func
        buttonFuncArgs = buttonInfo.funcArgs
        if not isinstance(buttonFunc, (types.MethodType, types.LambdaType)):
            return
        self.func = buttonFunc
        self.funcArgs = buttonFuncArgs
        self.commandName = getattr(buttonInfo, 'commandName', None)

    @telemetry.ZONE_METHOD
    def ShowButtonHilite(self):
        if self.isHilighted:
            return
        uicore.animations.FadeTo(self.hilite,
                                 self.hilite.opacity,
                                 0.15,
                                 duration=uiconst.TIME_ENTRY)
        self.isHilighted = True
        sm.GetService('audio').SendUIEvent('ui_radial_mouseover_play')
        self.icon.OnMouseEnter()

    @telemetry.ZONE_METHOD
    def HideButtonHilite(self):
        if not self.isHilighted:
            return
        uicore.animations.FadeTo(self.hilite,
                                 self.hilite.opacity,
                                 0.0,
                                 duration=uiconst.TIME_EXIT)
        self.isHilighted = False
        self.sliceInUse.Show()
        if self.isDisabled:
            self.icon.opacity = 0.4
        else:
            self.icon.opacity = 1.0
        self.icon.OnMouseExit()

    def ShowSelectionSlice(self):
        self.availableSlice.display = False
        self.unavailableSlice.display = False
        self.selectionSlice.display = True

    def SetIcon(self, texturePath):
        self.icon.SetTexturePath(texturePath)

    def SetDisabled(self):
        if self.sliceInUse != self.unavailableSlice:
            self.sliceInUse = self.unavailableSlice
            self.availableSlice.display = False
            self.unavailableSlice.display = True
        self.isDisabled = True
        self.icon.opacity = 0.4

    def SetEnabled(self):
        if self.sliceInUse != self.availableSlice:
            self.sliceInUse = self.availableSlice
            self.unavailableSlice.display = False
            self.availableSlice.display = True
        self.isDisabled = False
        self.icon.opacity = 1.0

    def AnimateSize(self, sizeRatio=0.5, duration=0.5, grow=True):
        if grow:
            startHeight = sizeRatio * self.fullHeight
            startWidth = sizeRatio * self.fullWidth
            endHeight = self.fullHeight
            endWidth = self.fullWidth
        else:
            startHeight = self.height
            startWidth = self.width
            endHeight = sizeRatio * self.fullHeight
            endWidth = sizeRatio * self.fullWidth
        uicore.animations.MorphScalar(self,
                                      'height',
                                      startVal=startHeight,
                                      endVal=endHeight,
                                      duration=duration)
        uicore.animations.MorphScalar(self,
                                      'width',
                                      startVal=startWidth,
                                      endVal=endWidth,
                                      duration=duration)

    def SelectButtonSlice(self, duration=0.5):
        self.ShowSelectionSlice()
        animationDuration = uix.GetTiDiAdjustedAnimationTime(duration,
                                                             minTiDiValue=0.1,
                                                             minValue=0.02)
        curvePoints = ([0.0, 0], [0.5, -10], [1, -10])
        uicore.animations.MorphScalar(self,
                                      'top',
                                      duration=animationDuration,
                                      curveType=curvePoints,
                                      sleep=False)
        curvePoints = ([0.0, self.selectionSlice.opacity
                        ], [0.5, self.selectionSlice.opacity], [0.6, 1.5],
                       [0.7, 0.5], [0.8, 1.5], [1, 0])
        uicore.animations.MorphScalar(self,
                                      'opacity',
                                      duration=animationDuration,
                                      curveType=curvePoints,
                                      sleep=True)
Exemplo n.º 6
0
class AchievementTreeSlot(Container):
    default_align = uiconst.TOPLEFT
    default_state = uiconst.UI_NORMAL
    default_pickRadius = -1
    nameLabel = None
    tooltipPanel = None
    localScale = 1.0
    moveEnabled = False

    def ApplyAttributes(self, attributes):
        Container.ApplyAttributes(self, attributes)
        self.achievementGroupID = attributes.achievementGroupID
        self.hexGridPosition = attributes.hexGridPosition
        self.nameLabel = InfoPanelLabel(parent=self.parent, state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT, idx=0)
        self.stateSprite = GlowSprite(parent=self, pos=(0, 0, 20, 20), align=uiconst.CENTER, state=uiconst.UI_DISABLED)
        self.activeEffectSprite = SpriteThemeColored(parent=self, state=uiconst.UI_DISABLED, spriteEffect=trinity.TR2_SFX_MODULATE, blendMode=trinity.TR2_SBM_ADDX2, texturePath='res:/UI/Texture/classes/Achievements/hexPingGlow.png', textureSecondaryPath='res:/UI/Texture/classes/Achievements/hexPingMask.png', pos=(0, 0, 300, 300), align=uiconst.CENTER, opacity=0.0)
        self.activeStateSprite = SpriteThemeColored(parent=self, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Achievements/hexActive.png', pos=(0, 0, 200, 200), align=uiconst.CENTER, opacity=0.0, blendMode=trinity.TR2_SBM_ADDX2, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
        self.backgroundSprite = SpriteThemeColored(bgParent=self, texturePath='res:/UI/Texture/classes/Achievements/hexBackIncomplete.png', colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.5)
        self.UpdateGroupState()

    def Close(self, *args, **kwds):
        if self.nameLabel and not self.nameLabel.destroyed:
            self.nameLabel.LoadTooltipPanel = None
            self.nameLabel.GetTooltipPosition = None
        return Container.Close(self, *args, **kwds)

    def GetTooltipPosition(self, *args, **kwds):
        return self.GetAbsolute()

    def UpdateGroupState(self):
        activeGroupID = sm.GetService('achievementSvc').GetActiveAchievementGroupID()
        groupData = GetAchievementGroup(self.achievementGroupID)
        totalNum = groupData.GetNumberOfTasks()
        completed = groupData.GetNumberOfCompleted()
        if totalNum == completed:
            self.stateSprite.SetTexturePath('res:/UI/Texture/classes/Achievements/iconComplete.png')
            self.progressState = STATE_COMPLETED
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackComplete.png'
        elif completed:
            if activeGroupID == self.achievementGroupID:
                self.stateSprite.SetTexturePath('res:/UI/Texture/classes/Achievements/iconPartialActive.png')
            else:
                self.stateSprite.SetTexturePath('res:/UI/Texture/classes/Achievements/iconPartial.png')
            self.progressState = STATE_INPROGRESS
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackIncomplete.png'
        else:
            if activeGroupID == self.achievementGroupID:
                self.stateSprite.SetTexturePath('res:/UI/Texture/classes/Achievements/iconIncompleteActive.png')
            else:
                self.stateSprite.SetTexturePath('res:/UI/Texture/classes/Achievements/iconIncomplete.png')
            self.progressState = STATE_INCOMPLETE
            self.backgroundSprite.texturePath = 'res:/UI/Texture/classes/Achievements/hexBackIncomplete.png'
        self.nameLabel.text = GetByLabel(groupData.groupName)
        if activeGroupID == self.achievementGroupID:
            self.activeEffectSprite.display = True
            self.activeStateSprite.display = True
            uicore.animations.FadeTo(self.activeEffectSprite, startVal=0.7, endVal=0.2, duration=0.5)
            r, g, b, a = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT)
            uicore.animations.MorphVector2(self.activeEffectSprite, 'scale', startVal=(2.5, 2.5), endVal=(0.0, 0.0), duration=0.7)
            uicore.animations.SpColorMorphTo(self.activeStateSprite, startColor=(0, 0, 0, 0), endColor=(r,
             g,
             b,
             1.0), duration=0.5, curveType=uiconst.ANIM_OVERSHOT, callback=self.PulseActive)
            uicore.animations.SpColorMorphTo(self.backgroundSprite, startColor=(r,
             g,
             b,
             0.5), endColor=(r,
             g,
             b,
             1.5), duration=0.1, curveType=uiconst.ANIM_OVERSHOT)
        else:
            uicore.animations.FadeOut(self.activeStateSprite, duration=0.125)
            uicore.animations.FadeOut(self.activeEffectSprite, duration=0.125)
            r, g, b, a = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHTGLOW)
            uicore.animations.SpColorMorphTo(self.backgroundSprite, startColor=(r,
             g,
             b,
             0.5), endColor=(r,
             g,
             b,
             0.5), duration=0.1, curveType=uiconst.ANIM_OVERSHOT)
        if self.tooltipPanel:
            tooltipPanel = self.tooltipPanel()
            if tooltipPanel and not tooltipPanel.destroyed:
                tooltipPanel.Flush()
                self.LoadTooltipPanel(tooltipPanel)

    def PulseActive(self):
        r, g, b, a = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT)
        uicore.animations.SpColorMorphTo(self.activeStateSprite, startColor=(r,
         g,
         b,
         1.0), endColor=(r * 0.8,
         g * 0.8,
         b * 0.8,
         1.0), duration=1.5, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT)

    def UpdateLabelPosition(self):
        if not self.nameLabel:
            return
        if self.localScale < 1.0:
            self.nameLabel.fontsize = fontConst.EVE_MEDIUM_FONTSIZE
        else:
            self.nameLabel.fontsize = fontConst.EVE_LARGE_FONTSIZE
        self.nameLabel.left = self.left + self.width / 2 + 14
        self.nameLabel.top = self.top + (self.height - self.nameLabel.textheight) / 2

    def SetLocalScale(self, localScale):
        self.localScale = localScale
        self.activeEffectSprite.width = self.activeEffectSprite.height = SLOT_SIZE * localScale * 3.0
        self.activeStateSprite.width = self.activeStateSprite.height = SLOT_SIZE * localScale * 2.0

    def OnClick(self, *args):
        from achievements.client.auraAchievementWindow import AchievementAuraWindow
        auraWindow = AchievementAuraWindow.GetIfOpen()
        if auraWindow:
            auraWindow.FadeOutTransitionAndClose()
        sm.GetService('achievementSvc').SetActiveAchievementGroupID(self.achievementGroupID)
        sm.GetService('experimentClientSvc').LogWindowOpenedActions('opportunitySelect')

    def OnMouseDown(self, *args):
        if session.role & (service.ROLE_GML | service.ROLE_WORLDMOD):
            self.moveEnabled = True

    def OnMouseUp(self, *args):
        if session.role & (service.ROLE_GML | service.ROLE_WORLDMOD):
            self.moveEnabled = False
            self._PrintPositions()

    def OnMouseMove(self, *args):
        if getattr(self, 'moveEnabled', False):
            pl, pt, pw, ph = self.parent.GetAbsolute()
            px_hx = pixel_to_hex(uicore.uilib.x - pl, uicore.uilib.y - pt, self.parent.hexGridSize * self.parent.localScale)
            ax_cu = axial_to_cube_coordinate(*px_hx)
            ax_cu_rounded = hex_round(*ax_cu)
            cu_ax = cube_to_odd_q_axial_coordinate(*ax_cu_rounded)
            self.SetHexGridPosition(*cu_ax)

    def SetHexGridPosition(self, hexColumn, hexRow):
        centerX, centerY = hex_slot_center_position(hexColumn, hexRow, self.parent.hexGridSize * self.parent.localScale)
        self.left = centerX - self.width / 2
        self.top = centerY - self.height / 2
        self.parent.UpdateTreePositions()
        self.hexGridPosition = (hexColumn, hexRow)

    def _PrintPositions(self):
        print '# -----------------------------------'
        for each in self.parent.children:
            if not isinstance(each, AchievementTreeSlot):
                continue
            centerX = each.left + each.width / 2
            centerY = each.top + each.height / 2
            px_hx = pixel_to_hex(centerX, centerY, self.parent.hexGridSize * self.parent.localScale)
            ax_cu = axial_to_cube_coordinate(*px_hx)
            ax_cu_rounded = hex_round(*ax_cu)
            cu_ax = cube_to_odd_q_axial_coordinate(*ax_cu_rounded)
            groupData = GetAchievementGroup(each.achievementGroupID)
            print 'group%s.SetTreePosition(%s) # %s' % (each.achievementGroupID, cu_ax, GetByLabel(groupData.groupName))

    def OnMouseEnter(self, *args):
        activeGroupID = sm.GetService('achievementSvc').GetActiveAchievementGroupID()
        if activeGroupID == self.achievementGroupID:
            r, g, b, a = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT)
            uicore.animations.SpColorMorphTo(self.backgroundSprite, startColor=(r,
             g,
             b,
             1.5), endColor=(r,
             g,
             b,
             3.0), duration=0.1, curveType=uiconst.ANIM_OVERSHOT)
        else:
            uicore.animations.FadeTo(self.backgroundSprite, startVal=self.backgroundSprite.opacity, endVal=1.0, duration=0.1, curveType=uiconst.ANIM_OVERSHOT)
        self.moTimer = AutoTimer(10, self.CheckMouseOver)
        if not SLOT_SHOW_MOUSEOVER_INFO:
            self.mouseEnterDelay = AutoTimer(300, self.CheckMouseEnter)

    def CheckMouseEnter(self, *args):
        self.mouseEnterDelay = None
        if uicore.uilib.mouseOver is self:
            sm.ScatterEvent('OnAchievementTreeMouseOver', self.achievementGroupID)

    def CheckMouseOver(self):
        if uicore.uilib.mouseOver is self:
            return
        if uicore.uilib.mouseOver.IsUnder(self):
            return
        if self.nameLabel and uicore.uilib.mouseOver is self.nameLabel:
            return
        self.moTimer = None
        activeGroupID = sm.GetService('achievementSvc').GetActiveAchievementGroupID()
        if activeGroupID == self.achievementGroupID:
            r, g, b, a = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT)
            uicore.animations.SpColorMorphTo(self.backgroundSprite, startColor=(r,
             g,
             b,
             1.5), endColor=(r,
             g,
             b,
             1.5), duration=0.1, curveType=uiconst.ANIM_OVERSHOT)
        else:
            uicore.animations.FadeTo(self.backgroundSprite, startVal=self.backgroundSprite.opacity, endVal=0.5, duration=0.1)

    def GetBounds(self):
        return (self.left,
         self.top,
         self.left + self.width,
         self.top + self.height)

    def LoadTooltipPanel(self, tooltipPanel, *args, **kwds):
        if not SLOT_SHOW_MOUSEOVER_INFO:
            return
        tooltipPanel.columns = 1
        tooltipPanel.margin = (10, 5, 10, 3)
        tooltipPanel.state = uiconst.UI_NORMAL
        groupData = GetAchievementGroup(self.achievementGroupID)
        if groupData:
            AchievementGroupEntry(parent=tooltipPanel, groupInfo=groupData, align=uiconst.TOPLEFT, width=240)

    def GetTooltipPosition(self, *args):
        return self.GetAbsolute()

    def GetTooltipPositionFallbacks(self, *args):
        return []

    def GetTooltipPointer(self, *args):
        return uiconst.POINT_TOP_2

    @apply
    def pos():
        fget = Container.pos.fget

        def fset(self, value):
            Container.pos.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())

    @apply
    def left():
        fget = Container.left.fget

        def fset(self, value):
            Container.left.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())

    @apply
    def top():
        fget = Container.top.fget

        def fset(self, value):
            Container.top.fset(self, value)
            self.UpdateLabelPosition()

        return property(**locals())