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

outcomeItemContainer.py (13676B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\industry\views\outcomeItemContainer.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui.const import CENTER
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.gradientSprite import GradientSprite
      6 from carbonui.primitives.sprite import Sprite, StreamingVideoSprite
      7 from eve.client.script.ui.control.eveIcon import Icon
      8 from eve.client.script.ui.control.eveLabel import EveLabelLargeBold
      9 from eve.client.script.ui.control.themeColored import FrameThemeColored, FillThemeColored
     10 from eve.client.script.ui.shared.cloneGrade import ORIGIN_INDUSTRY
     11 from eve.client.script.ui.shared.cloneGrade.omegaCloneOverlayIcon import OmegaCloneOverlayIcon
     12 from eve.client.script.ui.shared.industry import industryUIConst
     13 from eve.client.script.ui.shared.industry.industryUIConst import GetJobColor
     14 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame
     15 from eve.client.script.ui.shared.industry.views.industryTooltips import OutcomeTooltipPanel
     16 from eve.client.script.ui.shared.preview import PreviewContainer
     17 from eve.client.script.ui.util.uix import GetTechLevelIconPathAndHint
     18 from eve.common.script.sys.eveCfg import IsPreviewable
     19 import evetypes
     20 import industry
     21 import carbonui.const as uiconst
     22 from industry.const import RESEARCH_MATERIAL, RESEARCH_TIME
     23 from omega.client.clone_grade_svc import get_clone_grade_svc
     24 from utillib import KeyVal
     25 import trinity
     26 import blue
     27 import uthread
     28 from carbonui.uicore import uicore
     29 from eveservices.menu import GetMenuService
     30 
     31 class OutcomeItemContainer(Container):
     32     default_state = uiconst.UI_NORMAL
     33     default_clipChildren = True
     34     __notifyevents__ = ['OnIndustryViewExpandCollapse', 'OnIndustryWindowMinimized', 'OnIndustryWindowMaximized']
     35 
     36     def ApplyAttributes(self, attributes):
     37         Container.ApplyAttributes(self, attributes)
     38         sm.RegisterNotify(self)
     39         self.jobData = attributes.jobData
     40         self.videoThread = None
     41         self.omegaIcon = OmegaCloneOverlayIcon(parent=self, align=uiconst.TOALL, origin=ORIGIN_INDUSTRY)
     42         self.iconCont = Container(name='iconCont', parent=self, align=CENTER, state=uiconst.UI_NORMAL, width=64, height=64)
     43         self.errorFrame = ErrorFrame(parent=self, align=uiconst.CENTER, pos=(0, 0, 64, 64), state=uiconst.UI_HIDDEN)
     44         self.qtyLabel = EveLabelLargeBold(parent=self, align=CENTER, top=42)
     45         FrameThemeColored(name='bgVignette', parent=self, texturePath='res:/UI/Texture/Classes/Industry/Output/bgVignette.png', cornerSize=30)
     46         self.videoCont = Container(name='videoCont', parent=self, align=uiconst.CENTER, width=324, height=199)
     47         self.previewContFill = FillThemeColored(parent=self)
     48         self.previewCont = PreviewContainer(parent=self, align=uiconst.TOALL, state=uiconst.UI_HIDDEN)
     49         self.leftProbabilityGradient = GradientSprite(name='leftProbabilityGradient', parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_HIDDEN, pos=(0, 0, 160, 64), rgbData=((0, (1.0, 1.0, 1.0)),), alphaData=((0.0, 0.5), (1.0, 0.0)))
     50         self.rightProbabilityGradient = GradientSprite(name='rightProbabilityGradient', parent=self, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, pos=(0, 0, 160, 64), rgbData=((0, (1.0, 1.0, 1.0)),), alphaData=((0.0, 0.0), (1.0, 0.5)))
     51         self.previewCont.navigation.LoadTooltipPanel = self.LoadIconContTooltipPanel
     52         self.previewCont.navigation.GetMenu = self.GetMenu
     53         self.iconCont.LoadTooltipPanel = self.LoadIconContTooltipPanel
     54         self.iconCont.OnMouseEnter = self.OnIconContMouseEnter
     55         self.iconCont.OnMouseExit = self.OnIconContMouseExit
     56         self.iconCont.OnClick = self.OnIconContClick
     57         self.iconCont.GetMenu = self.GetMenu
     58         self.iconCont.GetDragData = self.GetIconContDragData
     59         self.iconCont.isDragObject = True
     60         self.techIcon = Sprite(name='techIcon', parent=self.iconCont, width=16, height=16)
     61         self.icon = Icon(parent=self.iconCont, align=CENTER, state=uiconst.UI_DISABLED)
     62         self.bgCont = Container(name='bgCont', parent=self, align=uiconst.CENTER, width=201, height=192)
     63         self.bg = Sprite(bgParent=self.bgCont, texturePath='res:/UI/Texture/Classes/Industry/Output/itemBg.png')
     64         self.itemPattern = Sprite(bgParent=self.bgCont, texturePath='res:/UI/Texture/Classes/Industry/Output/itemBgColor.png')
     65         self.isShowing3DOutputPreview = False
     66         self.UpdateState()
     67         self.AnimEntry()
     68 
     69     def OnIndustryViewExpandCollapse(self):
     70         if not self.previewCont or not self.jobData or self.jobData.activityID != industry.MANUFACTURING:
     71             return
     72         isCollapsed = settings.user.ui.Get('industryWndIsViewCollapsed', False)
     73         if not isCollapsed and IsPreviewable(self.jobData.GetProductTypeID()):
     74             self.AnimFadeSceneContIn()
     75         else:
     76             self.previewCont.Hide()
     77             self.previewContFill.opacity = 1.0
     78 
     79     def OnIndustryWindowMinimized(self):
     80         if self.isShowing3DOutputPreview:
     81             self.previewCont.Hide()
     82             self.previewContFill.opacity = 1.0
     83 
     84     def OnIndustryWindowMaximized(self):
     85         if self.isShowing3DOutputPreview:
     86             self.previewCont.Show()
     87             self.previewContFill.opacity = 0.0
     88 
     89     def AnimFadeSceneContIn(self):
     90         self.previewCont.Hide()
     91         self.previewContFill.opacity = 1.0
     92         blue.synchro.SleepWallclock(250)
     93         self.previewCont.Show()
     94         uicore.animations.FadeTo(self.previewContFill, 1.0, 0.0, duration=0.6)
     95 
     96     def OnNewJobData(self, jobData):
     97         self.jobData = jobData
     98         self.UpdateState()
     99         if self.jobData:
    100             self.jobData.on_updated.connect(self.UpdateState)
    101         self.AnimEntry()
    102 
    103     def UpdateState(self, *args):
    104         if not self.jobData:
    105             self.previewCont.Hide()
    106             return
    107         productTypeID = self.jobData.GetProductTypeID()
    108         if IsPreviewable(productTypeID) and self.jobData.activityID == industry.MANUFACTURING:
    109             self.isShowing3DOutputPreview = True
    110             self.previewCont.Show()
    111             self.iconCont.Hide()
    112             newModel = self.previewCont.PreviewType(productTypeID)
    113             if self.destroyed:
    114                 return
    115             if newModel:
    116                 self.previewContFill.Show()
    117                 self.previewContFill.opacity = 1.0
    118                 self.previewCont.AnimEntry()
    119                 self.previewCont.sceneContainer.scene.sunDirection = (-0.5, -1.0, -1.0)
    120             self.bg.Hide()
    121             self.qtyLabel.top = 86
    122             self.leftProbabilityGradient.Hide()
    123             self.rightProbabilityGradient.Hide()
    124         else:
    125             self.isShowing3DOutputPreview = False
    126             self.iconCont.Show()
    127             self.previewCont.Hide()
    128             self.bg.Show()
    129             self.qtyLabel.top = 42
    130             if self.jobData.activityID == industry.RESEARCH_MATERIAL:
    131                 self.icon.LoadIcon('res:/UI/Texture/Classes/Industry/iconME.png')
    132                 self.icon.width = self.icon.height = 17
    133                 self.techIcon.texturePath = None
    134             elif self.jobData.activityID == industry.RESEARCH_TIME:
    135                 self.icon.LoadIcon('res:/UI/Texture/Classes/Industry/iconTE.png')
    136                 self.techIcon.texturePath = None
    137                 self.icon.width = self.icon.height = 16
    138             else:
    139                 isCopy = self.jobData.activityID in (industry.COPYING, industry.INVENTION)
    140                 oldTypeID = self.icon.typeID
    141                 self.icon.LoadIconByTypeID(productTypeID, ignoreSize=True, isCopy=isCopy)
    142                 self.icon.width = self.icon.height = 64
    143                 texturePath, hint = GetTechLevelIconPathAndHint(productTypeID)
    144                 self.techIcon.texturePath = texturePath
    145                 self.techIcon.hint = hint
    146                 if oldTypeID != productTypeID:
    147                     uicore.animations.FadeTo(self.icon, 0.0, 1.0, duration=0.6)
    148             if self.jobData.activityID == industry.INVENTION:
    149                 width = self.jobData.probability * 160
    150                 color = GetJobColor(self.jobData)
    151                 for gradient in (self.leftProbabilityGradient, self.rightProbabilityGradient):
    152                     gradient.Show()
    153                     gradient.SetRGBA(*color)
    154                     uicore.animations.MorphScalar(gradient, 'width', gradient.width, width, duration=0.6)
    155 
    156             else:
    157                 self.leftProbabilityGradient.Hide()
    158                 self.rightProbabilityGradient.Hide()
    159         if self.jobData and self.jobData.product:
    160             self.iconCont.opacity = 1.0
    161             uicore.animations.FadeTo(self.bgCont, self.bgCont.opacity, 1.0, duration=0.3)
    162             self.errorFrame.Hide()
    163         else:
    164             self.iconCont.opacity = 0.0
    165             uicore.animations.FadeTo(self.bgCont, 0.3, 1.0, duration=2.0, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT)
    166             self.errorFrame.Show()
    167         self.UpdateOutputQty()
    168         isOmegaItem = False if productTypeID is None else get_clone_grade_svc().is_restricted_for_alpha(productTypeID)
    169         if isOmegaItem and self.jobData.activityID not in (RESEARCH_MATERIAL, RESEARCH_TIME):
    170             self.omegaIcon.state = uiconst.UI_DISABLED
    171         else:
    172             self.omegaIcon.Hide()
    173         self.StopVideo()
    174         if self.jobData.status == industry.STATUS_DELIVERED:
    175             self.PlayVideoDelivered()
    176 
    177     def PlayVideoDelivered(self):
    178         self.PlayVideo('res:/video/Industry/deliveredIntro.webm', 'res:/video/Industry/deliveredOutro.webm', industryUIConst.GetActivityColor(self.jobData.activityID))
    179 
    180     def PlayVideoFailed(self):
    181         self.PlayVideo('res:/video/Industry/failedIntro.webm', 'res:/video/Industry/failedOutro.webm', industryUIConst.COLOR_NOTREADY)
    182 
    183     def StopVideo(self):
    184         if self.videoThread:
    185             self.videoThread.kill()
    186             self.videoCont.Flush()
    187 
    188     def PlayVideo(self, introPath, outroPath, color):
    189         self.videoThread = uthread.new(self._PlayVideo, introPath, outroPath, color)
    190 
    191     def _PlayVideo(self, introPath, outroPath, color):
    192         self.videoCont.Flush()
    193         videoSprite = StreamingVideoSprite(parent=self.videoCont, align=uiconst.TOALL, spriteEffect=trinity.TR2_SFX_COPY, videoPath=introPath, color=color)
    194         while not videoSprite.isFinished:
    195             blue.synchro.Yield()
    196 
    197         blue.synchro.SleepWallclock(3000)
    198         videoSprite.Close()
    199         videoSprite = StreamingVideoSprite(parent=self.videoCont, align=uiconst.TOALL, spriteEffect=trinity.TR2_SFX_COPY, videoPath=outroPath, color=color)
    200         while not videoSprite.isFinished:
    201             blue.synchro.Yield()
    202 
    203         uicore.animations.FadeOut(videoSprite, callback=videoSprite.Close)
    204 
    205     def GetMenu(self):
    206         if not self.jobData.product:
    207             return None
    208         abstractInfo = KeyVal(bpData=self.GetBpData())
    209         return GetMenuService().GetMenuFromItemIDTypeID(None, self.jobData.product.typeID, includeMarketDetails=True, abstractInfo=abstractInfo)
    210 
    211     def LoadIconContTooltipPanel(self, tooltipPanel, *args):
    212         if self.jobData.activityID in (industry.RESEARCH_TIME, industry.RESEARCH_MATERIAL):
    213             return
    214         self.tooltipPanel = OutcomeTooltipPanel(jobData=self.jobData, tooltipPanel=tooltipPanel)
    215 
    216     def GetIconContDragData(self, *args):
    217         typeID = self.jobData.GetProductTypeID()
    218         if not typeID:
    219             return
    220         if isinstance(self.jobData.product, industry.Blueprint):
    221             bpData = self.jobData.product.GetCopy()
    222         else:
    223             bpData = None
    224         return [KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=typeID, label=evetypes.GetName(typeID), bpData=bpData)]
    225 
    226     def UpdateOutputQty(self):
    227         if not self.jobData or not self.jobData.product:
    228             self.qtyLabel.text = ''
    229             return
    230         self.qtyLabel.text = self.jobData.GetProductAmountLabel()
    231 
    232     def AnimEntry(self):
    233         if not self.jobData:
    234             return
    235         uicore.animations.FadeTo(self.itemPattern, 0.0, 1.0, duration=0.6, timeOffset=1.35)
    236         uicore.animations.FadeTo(self.previewContFill, self.previewContFill.opacity, 0.0, duration=0.6, timeOffset=0, callback=self.previewContFill.Hide)
    237 
    238     def GetBpData(self):
    239         if not isinstance(self.jobData.product, industry.Blueprint):
    240             return None
    241         return self.jobData.product.GetCopy()
    242 
    243     def OnIconContClick(self, *args):
    244         if not self.jobData:
    245             return
    246         if self.jobData.activityID in (industry.RESEARCH_MATERIAL, industry.RESEARCH_TIME):
    247             return
    248         typeID = self.jobData.GetProductTypeID()
    249         if not typeID:
    250             return
    251         sm.GetService('info').ShowInfo(typeID, abstractinfo=KeyVal(bpData=self.GetBpData()))
    252         PlaySound(uiconst.SOUND_BUTTON_CLICK)
    253 
    254     def OnIconContMouseEnter(self, *args):
    255         uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.15)
    256         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    257 
    258     def OnIconContMouseExit(self, *args):
    259         uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3)
    260 
    261     def OnMouseEnter(self, *args):
    262         if self.omegaIcon.display:
    263             self.omegaIcon.OnMouseEnter()
    264 
    265     def OnMouseExit(self, *args):
    266         if self.omegaIcon.display:
    267             self.omegaIcon.OnMouseExit()
    268 
    269     def OnClick(self, *args):
    270         if self.omegaIcon.display:
    271             self.omegaIcon.OnClick()
    272 
    273     def GetHint(self):
    274         if self.omegaIcon.display:
    275             return self.omegaIcon.GetHint()