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

activityListCont.py (5818B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\activities\activityListCont.py
      2 import uthread2
      3 from carbonui import uiconst
      4 from carbonui.control.scrollContainer import ScrollContainer
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.sprite import StreamingVideoSprite
      7 from eve.client.script.ui.control.eveLabel import EveLabelLarge
      8 from carbonui.window.underlay import WindowUnderlay
      9 from eve.client.script.ui.shared.activities.activitiesUIConst import ACTIVITY_COUNT_LAYER_COLOR, ACTIVITY_ENTRY_HEIGHT, BANNER_SPRITE_HEIGHT, BANNER_SPRITE_WIDTH, LABEL_ACTIVITY_COUNT, SCROLL_ELEMENT_BOTTOM_PADDING, SCROLL_ELEMENT_LEFT_PADDING, SCROLL_ELEMENT_RIGHT_PADDING, SCROLL_HEIGHT, SCROLL_LAYER_COLOR, SCROLL_PADDING_HEIGHT, SCROLL_SECTION_HEADER_HEIGHT, SCROLL_SECTION_HEIGHT, SCROLL_SECTION_REST_HEIGHT, SCROLL_SECTION_RIGHT_PADDING, SCROLL_SECTION_WIDTH
     10 from eve.client.script.ui.shared.activities.activityEntry import ActivityEntry
     11 from eve.client.script.ui.structure import ChangeSignalConnect
     12 from carbonui.control.button import Button
     13 from eveui import Sprite
     14 import localization
     15 
     16 class ActivityCountHeaderCont(Container):
     17     default_name = 'HeaderCont'
     18     default_bgColor = (0.5, 0.5, 0.5, 0.3)
     19     default_height = SCROLL_SECTION_HEADER_HEIGHT
     20 
     21     def ApplyAttributes(self, attributes):
     22         super(ActivityCountHeaderCont, self).ApplyAttributes(attributes)
     23         text = attributes.text
     24         self.label = EveLabelLarge(parent=self, align=uiconst.CENTER, text=text)
     25 
     26     def SetText(self, text):
     27         self.label.SetText(text)
     28 
     29 
     30 class ActivityListCont(Container):
     31 
     32     def ApplyAttributes(self, attributes):
     33         Container.ApplyAttributes(self, attributes)
     34         self.service = sm.GetService('activities')
     35         self.ConstructBanner()
     36         self.ConstructBackground()
     37         self.ConstructScrollSection()
     38         self.ChangeSignalConnection(connect=True)
     39         self.LoadActivities()
     40 
     41     def ConstructBanner(self):
     42         self.bannerSprite = Sprite(name='bannerSprite', parent=self, align=uiconst.CENTERLEFT, width=BANNER_SPRITE_WIDTH, height=BANNER_SPRITE_HEIGHT, textureSecondaryPath='res:/UI/Texture/classes/newFeatureNotify/mask_Window.png')
     43         self.bannerVideoSprite = StreamingVideoSprite(name='bannerVideoSprite', parent=self, align=uiconst.CENTERLEFT, width=BANNER_SPRITE_WIDTH, height=BANNER_SPRITE_HEIGHT, textureSecondaryPath='res:/UI/Texture/classes/newFeatureNotify/mask_Window.png')
     44         self.ConstructButtons(BANNER_SPRITE_WIDTH, BANNER_SPRITE_HEIGHT)
     45         self.bannerSpriteColor = self.bannerSprite.GetRGBA()
     46 
     47     def ConstructScrollSection(self):
     48         self.scrollSection = Container(name='scrollSection', parent=self, state=uiconst.UI_NORMAL, align=uiconst.CENTERRIGHT, width=SCROLL_SECTION_WIDTH, height=SCROLL_SECTION_HEIGHT, left=SCROLL_SECTION_RIGHT_PADDING, idx=0)
     49         count = localization.formatters.FormatNumeric(self.service.GetActivityCount())
     50         self.headerCont = ActivityCountHeaderCont(parent=self.scrollSection, align=uiconst.TOTOP, bgColor=ACTIVITY_COUNT_LAYER_COLOR, text=localization.GetByLabel(LABEL_ACTIVITY_COUNT, count=count))
     51         self.bottomSection = Container(name='bottomSection', parent=self.scrollSection, align=uiconst.TOBOTTOM, height=SCROLL_SECTION_REST_HEIGHT, bgColor=SCROLL_LAYER_COLOR)
     52         self.scrollCont = Container(name='scrollCont', parent=self.bottomSection, padTop=SCROLL_PADDING_HEIGHT, align=uiconst.TOTOP, height=SCROLL_HEIGHT)
     53         self.contentScroll = ScrollContainer(parent=self.scrollCont)
     54 
     55     def ConstructBackground(self):
     56         self.underlay = WindowUnderlay(parent=self)
     57         self.underlay.SetState(uiconst.UI_DISABLED)
     58 
     59     def ChangeSignalConnection(self, connect = True):
     60         signalAndCallback = [(self.service.OnActivitySelected, self.ActivitySelected)]
     61         ChangeSignalConnect(signalAndCallback, connect)
     62 
     63     def ConstructButtons(self, mainSpriteWidth, mainSpriteHeight):
     64         callToActionButton = Button(name='callToActionButton', parent=self, align=uiconst.CENTERLEFT, func=self.OnBannerClicked, opacity=0, idx=0)
     65         callToActionButton.width = mainSpriteWidth
     66         callToActionButton.height = mainSpriteHeight
     67 
     68     def OnBannerClicked(self, *args):
     69         self.service.OnBannerClicked()
     70 
     71     def ShowFirst(self):
     72         self.service.SelectActivity()
     73 
     74     def ActivitySelected(self, activity):
     75         self._UpdateCardSelectedState(activity)
     76         self.ShowBanner(activity)
     77 
     78     def ShowBanner(self, activity):
     79         uthread2.start_tasklet(self._OnShow, activity)
     80 
     81     def _OnShow(self, activity):
     82         self._UpdateSpriteAndVideoSprite(activity)
     83 
     84     def _UpdateSpriteAndVideoSprite(self, activity):
     85         if activity.IsVideo():
     86             self.bannerVideoSprite.SetVideoPath(activity.GetTexturePath(), videoLoop=True)
     87         else:
     88             self.bannerSprite.texturePath = activity.GetTexturePath()
     89         self.bannerSprite.display = not activity.IsVideo()
     90         self.bannerVideoSprite.display = activity.IsVideo()
     91 
     92     def _UpdateCardSelectedState(self, activity):
     93         for entry in self.activityEntrys:
     94             if entry.GetActivity() == activity:
     95                 entry.Select()
     96             else:
     97                 entry.Deselect()
     98 
     99     def LoadActivities(self, **args):
    100         datas = self.service.GetActivities()
    101         if not datas:
    102             return
    103         self.activityEntrys = [ ActivityEntry(parent=self.contentScroll, data=element, padLeft=SCROLL_ELEMENT_LEFT_PADDING, padRight=SCROLL_ELEMENT_RIGHT_PADDING, padBottom=SCROLL_ELEMENT_BOTTOM_PADDING, align=uiconst.TOTOP, opacity=1.0, height=ACTIVITY_ENTRY_HEIGHT) for element in datas ]
    104 
    105     def Close(self):
    106         self.ChangeSignalConnection(connect=False)
    107         Container.Close(self)