NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

activityEntry.py (9100B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\activities\activityEntry.py
      2 import math
      3 from carbonui.fontconst import STYLE_SMALLTEXT
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.frame import Frame
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.primitives.stretchspritehorizontal import StretchSpriteHorizontal
      8 from carbonui.util.color import Color
      9 from carbonui import uiconst
     10 from carbonui.primitives.containerAutoSize import ContainerAutoSize
     11 from carbonui.uianimations import animations
     12 from eve.client.script.ui.control.eveLabel import EveLabelSmall, EveLabelMediumBold, EveStyleLabel
     13 from eve.client.script.ui.shared.activities.activitiesUIConst import OPACITY_SELECTED, OPACITY_HOVER, ACTIVITY_ENTRY_HEIGHT, SCROLL_WIDTH, BADGE_COLOR, DEFAULT_DIAMETER, SCROLL_ELEMENT_INTRODUCE_WIDTH, SCROLL_ELEMENT_INTRODUCE_HEIGHT, SCROLL_ELEMENT_INTRODUCE_BOTTOM_PADDING, SCROLL_ELEMENT_INTRODUCE_RIGHT_PADDING, SCROLL_ELEMENT_TITLE_WIDTH, SCROLL_ELEMENT_TITLE_HEIGHT, SCROLL_ELEMENT_TITLE_TOP_PADDING, SCROLL_ELEMENT_ICON_PARENT_WIDTH, SCROLL_ELEMENT_ICON_WIDTH, SCROLL_ELEMENT_ICON_HEIGHT, SCROLL_ELEMENT_INTRODUCE_DISPLAY_WIDTH
     14 
     15 class CountdownLabelBold(EveStyleLabel):
     16     __guid__ = 'uicontrols.CountdownLabelBold'
     17     default_name = 'EveLabelSmallBold'
     18     default_fontStyle = STYLE_SMALLTEXT
     19     default_fontsize = 8
     20     default_bold = True
     21 
     22 
     23 class ActivityEntry(ContainerAutoSize):
     24     default_name = 'activityEntry'
     25     contentType = None
     26     default_state = uiconst.UI_NORMAL
     27     hasTimer = False
     28     isDragObject = True
     29     default_scalingCenter = (0.5, 0.5)
     30     default_opacity = 0.0
     31     default_minHeight = ACTIVITY_ENTRY_HEIGHT
     32     default_width = SCROLL_WIDTH
     33     default_alignMode = uiconst.TOTOP
     34 
     35     def ApplyAttributes(self, attributes):
     36         super(ActivityEntry, self).ApplyAttributes(attributes)
     37         self.isSelected = False
     38         self.ConstructData(attributes)
     39         self.ConstructBackground()
     40         self.ConstructIconContainer()
     41         self.ConstructMainContainer()
     42         self.ConstructBottomCont()
     43         self.ConstructIcon()
     44         self.ConstructContent()
     45         self.SetContent()
     46         self.ConstructRedDot()
     47         self.ConstructCountdown()
     48         self.AfterAllInitialize()
     49 
     50     def AfterAllInitialize(self):
     51         value = self.data.GetTimeLeftText()
     52         redDotOpacity = 1 if self.data.IsUnseen() else 0
     53         textOpacity = 0
     54         if value is not None:
     55             self.label.SetText(value)
     56             redDotOpacity = 0
     57             textOpacity = 1
     58         self._ShowText(textOpacity)
     59         self._ShowRedDot(redDotOpacity)
     60 
     61     def ConstructData(self, attributes):
     62         self.data = attributes.data
     63         self.activityID = self.data.GetID()
     64         self.service = sm.GetService('activities')
     65 
     66     def ConstructBackground(self):
     67         self.backgroundContainer = Container(name='backgroundContainer', bgParent=self, opacity=0.1)
     68         self.cornerTriangle = Sprite(name='cornerTriSmall', parent=self, align=uiconst.TOPLEFT, texturePath='res:/UI/Texture/Shared/DarkStyle/cornerTriSmall.png', width=5, height=5, opacity=0.3)
     69         StretchSpriteHorizontal(name='contentCardTop', parent=self.backgroundContainer, align=uiconst.TOTOP_NOPUSH, texturePath='res:/UI/Texture/classes/Agency/contentCardTop.png', height=11, leftEdgeSize=9)
     70         StretchSpriteHorizontal(name='contentCardBot', parent=self.backgroundContainer, align=uiconst.TOBOTTOM_NOPUSH, texturePath='res:/UI/Texture/classes/Agency/contentCardTop.png', height=11, rotation=math.pi, leftEdgeSize=9)
     71         self.strokeFrame = Frame(name='strokeFrame', parent=self, texturePath='res:/UI/Texture/Shared/DarkStyle/panel2Corner_Stroke.png', opacity=0.1, cornerSize=9)
     72         self.selectedFill = Frame(name='selected', bgParent=self, texturePath='res:/UI/Texture/Shared/DarkStyle/panel2Corner_Solid.png', color=Color.WHITE, opacity=0.0, cornerSize=9)
     73         self.hoverFill = Frame(name='selected', bgParent=self, texturePath='res:/UI/Texture/Shared/DarkStyle/panel2Corner_Solid.png', color=Color.WHITE, opacity=0.0, cornerSize=9)
     74         Frame(name='bgFill', bgParent=self, texturePath='res:/UI/Texture/Shared/DarkStyle/panel2Corner_Solid.png', color=Color.BLACK, opacity=0.9, cornerSize=9)
     75 
     76     def ConstructIconContainer(self):
     77         leftCont = Container(name='iconCont', parent=self, align=uiconst.TOLEFT, width=SCROLL_ELEMENT_ICON_PARENT_WIDTH)
     78         self.iconCont = Container(name='iconCont', parent=leftCont, align=uiconst.CENTER, pos=(0,
     79          0,
     80          SCROLL_ELEMENT_ICON_WIDTH,
     81          SCROLL_ELEMENT_ICON_HEIGHT))
     82 
     83     def ConstructMainContainer(self):
     84         self.mainCont = Container(name='mainCont', parent=self, align=uiconst.TOTOP, width=SCROLL_ELEMENT_TITLE_WIDTH, height=SCROLL_ELEMENT_TITLE_HEIGHT, padTop=SCROLL_ELEMENT_TITLE_TOP_PADDING, clipChildren=True)
     85 
     86     def ConstructBottomCont(self):
     87         self.bottomCont = Container(name='bottomCont', parent=self, align=uiconst.TOBOTTOM, width=SCROLL_ELEMENT_INTRODUCE_WIDTH, height=SCROLL_ELEMENT_INTRODUCE_HEIGHT, padRight=SCROLL_ELEMENT_INTRODUCE_RIGHT_PADDING, padBottom=SCROLL_ELEMENT_INTRODUCE_BOTTOM_PADDING)
     88         Frame(bgParent=self.bottomCont, texturePath='res:/UI/Texture/Shared/DarkStyle/panel1Corner_Solid.png', cornerSize=9, color=(0, 0, 0, 0.25))
     89 
     90     def ConstructIcon(self):
     91         iconSize = SCROLL_ELEMENT_ICON_WIDTH
     92         Sprite(name='icon', parent=self.iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0,
     93          0,
     94          iconSize,
     95          iconSize), texturePath=self.data.GetIconPath())
     96 
     97     def ConstructContent(self):
     98         self.ConstructTitleLabel()
     99         self.ConstructBottomLabel()
    100 
    101     def ConstructTitleLabel(self):
    102         self.titleLabel = EveLabelMediumBold(name='titleLabel', parent=self.mainCont, maxLines=1, width=SCROLL_ELEMENT_TITLE_WIDTH, left=4, align=uiconst.CENTERLEFT, color=(1, 1, 1, 1), state=uiconst.UI_NORMAL)
    103         self.titleLabel.OnClick = self.OnClick
    104 
    105     def ConstructBottomLabel(self):
    106         self.bottomLabel = EveLabelSmall(parent=self.bottomCont, width=SCROLL_ELEMENT_INTRODUCE_DISPLAY_WIDTH, name='bottomLabel', align=uiconst.CENTERLEFT, maxLines=1, padLeft=4)
    107 
    108     def SetContent(self):
    109         self.titleLabel.SetText(self.data.GetName())
    110         self.bottomLabel.SetText(self.data.GetIntroduce())
    111 
    112     def ConstructRedDot(self):
    113         self.badgeContainer = Container(name='badgeContainer', parent=self, padRight=8, padTop=8, align=uiconst.TOPRIGHT, width=DEFAULT_DIAMETER, height=DEFAULT_DIAMETER, opacity=0)
    114         self.frame = Frame(name='badgeFrame', bgParent=self.badgeContainer, texturePath='res:/UI/Texture/Shared/counterFrame.png', cornerSize=0, color=BADGE_COLOR)
    115 
    116     def ConstructCountdown(self):
    117         self.textContainer = Container(name='textContainer', parent=self, align=uiconst.TOPRIGHT, width=58, height=14, opacity=1, bgColor=BADGE_COLOR, idx=0)
    118         self.label = CountdownLabelBold(parent=self.textContainer, top=-1, align=uiconst.CENTER, color=Color.WHITE)
    119 
    120     def Select(self):
    121         self.isSelected = True
    122         animations.StopAllAnimations(self.selectedFill)
    123         animations.StopAllAnimations(self.cornerTriangle)
    124         animations.FadeTo(self.selectedFill, self.selectedFill.opacity, OPACITY_SELECTED, duration=0.4)
    125         animations.FadeTo(self.cornerTriangle, self.cornerTriangle.opacity, 1.0, duration=0.4)
    126 
    127     def Deselect(self):
    128         self.isSelected = False
    129         animations.StopAllAnimations(self.selectedFill)
    130         animations.StopAllAnimations(self.cornerTriangle)
    131         animations.FadeTo(self.selectedFill, self.selectedFill.opacity, 0.0, duration=0.4)
    132         animations.FadeTo(self.cornerTriangle, self.cornerTriangle.opacity, 0.3, duration=0.4)
    133 
    134     def OnMouseEnter(self, *args):
    135         sm.GetService('audio').SendUIEvent(uiconst.SOUND_ENTRY_HOVER)
    136         animations.StopAllAnimations(self.hoverFill)
    137         animations.FadeTo(self.hoverFill, self.hoverFill.opacity, OPACITY_HOVER, duration=0.1)
    138 
    139     def OnMouseExit(self, *args):
    140         animations.StopAllAnimations(self.hoverFill)
    141         animations.FadeTo(self.hoverFill, self.hoverFill.opacity, 0.0, duration=0.2)
    142 
    143     def AnimEnter(self, offsetIdx = 0):
    144         timeOffset = 0.05 * offsetIdx
    145         duration = 0.3
    146         animations.StopAllAnimations(self)
    147         animations.Tr2DScaleTo(self, (0.9, 0.9), (1.0, 1.0), duration=duration, timeOffset=timeOffset)
    148         animations.FadeIn(self, duration=2 * duration, timeOffset=timeOffset)
    149 
    150     def OnClick(self, *args):
    151         sm.GetService('audio').SendUIEvent('agency_window5_play')
    152         sm.GetService('audio').SendUIEvent(uiconst.SOUND_ENTRY_SELECT)
    153         self.OnEntrySelected(*args)
    154 
    155     def GetActivity(self):
    156         return self.data
    157 
    158     def _ShowRedDot(self, opacity = 1):
    159         self.badgeContainer.opacity = opacity
    160 
    161     def _ShowText(self, opacity = 1):
    162         self.textContainer.opacity = opacity
    163 
    164     def OnEntrySelected(self, *args):
    165         self.service.SelectActivity(self.activityID)
    166         self._ShowRedDot(0)