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

outputFramedContainers.py (11593B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\industry\views\outputFramedContainers.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui.const import CENTERRIGHT, TOALL, UI_NORMAL, UI_DISABLED
      4 from carbonui import Density
      5 from carbonui.control.combo import Combo
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      8 from carbonui.primitives.frame import Frame
      9 from carbonui.primitives.sprite import Sprite
     10 from carbonui.util.color import Color
     11 from carbonui.control.buttonIcon import ButtonIcon
     12 from eve.client.script.environment import invControllers as invCtrl
     13 from eve.client.script.ui.control.eveIcon import Icon
     14 from eve.client.script.ui.control.eveLabel import EveLabelSmall
     15 from eve.client.script.ui.control.themeColored import FrameThemeColored, FillThemeColored
     16 from eve.client.script.ui.shared.industry.industryUIConst import GetJobColor
     17 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame
     18 from eve.client.script.ui.shared.industry.views.industryCaptionLabel import IndustryCaptionLabel
     19 from eve.client.script.ui.shared.inventory.invWindow import Inventory
     20 import industry
     21 from eve.common.script.util import industryCommon
     22 import localization
     23 import carbonui.const as uiconst
     24 import telemetry
     25 from localization import GetByLabel
     26 from carbonui.uicore import uicore
     27 from eveservices.menu import GetMenuService
     28 OPACITY_IDLE = 0.02
     29 OPACITY_HOVER = 0.06
     30 OPACITY_FRAME = 0.1
     31 COLOR_FRAME = (0.12, 0.12, 0.12, 1.0)
     32 
     33 class BaseFramedContainer(Container):
     34     default_state = UI_NORMAL
     35     default_width = 304
     36     default_height = 44
     37 
     38     def ApplyAttributes(self, attributes):
     39         Container.ApplyAttributes(self, attributes)
     40         self.jobData = attributes.jobData
     41         self.oldJobData = None
     42         self.pattern = Frame(parent=self, texturePath='res:/UI/Texture/Classes/Industry/Output/boxPattern.png', align=TOALL, state=UI_DISABLED, opacity=0.0, cornerSize=5)
     43         FrameThemeColored(parent=self, state=UI_DISABLED, align=TOALL, opacity=0.3)
     44         FillThemeColored(bgParent=self, opacity=0.5)
     45         self.contentCont = Container(name='contentCont', parent=self)
     46         self.errorFrame = ErrorFrame(bgParent=self, padding=1)
     47         self.openInventoryBtn = ButtonIcon(name='openInventoryBtn ', parent=self, align=uiconst.TOPRIGHT, pos=(1, 1, 21, 21), iconSize=16, texturePath='res:/UI/Texture/Vgs/Search_icon.png', func=self.OnOpenInventoryBtn)
     48         self.UpdateState()
     49         self.AnimEntry()
     50 
     51     def GetInvControllersAndLocations(self):
     52         if self.jobData:
     53             return self.jobData.GetLocationsInvControllersAndLocations()
     54         return []
     55 
     56     def OnNewJobData(self, jobData):
     57         self.oldJobData = self.jobData
     58         self.jobData = jobData
     59         if jobData:
     60             self.jobData.on_updated.connect(self.OnJobDataUpdated)
     61         self.UpdateState()
     62         self.AnimEntry()
     63 
     64     def AnimEntry(self):
     65         color = GetJobColor(self.jobData)
     66         uicore.animations.SpColorMorphTo(self.pattern, self.pattern.GetRGBA(), color, duration=0.3)
     67 
     68     def OnJobDataUpdated(self, jobData):
     69         self.oldJobData = self.jobData
     70         self.UpdateState()
     71 
     72     def OnOpenInventoryBtn(self, *args):
     73         pass
     74 
     75 
     76 class FacilityContainer(BaseFramedContainer):
     77     default_name = 'facilityContainer'
     78 
     79     def ApplyAttributes(self, attributes):
     80         BaseFramedContainer.ApplyAttributes(self, attributes)
     81         self.labelCont = Container(parent=self.contentCont, align=uiconst.CENTERLEFT, left=8, width=237, height=38)
     82         IndustryCaptionLabel(parent=self.labelCont, align=uiconst.TOPLEFT, text=localization.GetByLabel('UI/Industry/Facility'))
     83         self.label = EveLabelSmall(parent=self.labelCont, align=uiconst.TOPLEFT, top=16, autoFadeSides=10)
     84         self.icon = Icon(name='installationIcon', parent=self.contentCont, align=CENTERRIGHT, state=UI_DISABLED, pos=(1, 0, 43, 42))
     85         self.removeIcon = Sprite(parent=self.contentCont, align=uiconst.TOPRIGHT, state=uiconst.UI_DISABLED, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(46, 2, 12, 12), color=Color.RED, opacity=0.0)
     86 
     87     @telemetry.ZONE_METHOD
     88     def UpdateState(self):
     89         if self.jobData:
     90             if self.jobData.facilityID:
     91                 self.icon.Show()
     92                 self.icon.LoadIconByTypeID(typeID=self.jobData.GetFacilityType(), ignoreSize=True)
     93                 self.label.text = self.jobData.GetFacilityName()
     94                 if self.IsFacilityChanged():
     95                     uicore.animations.FadeTo(self.labelCont, 0.0, 1.0, duration=0.6)
     96             else:
     97                 self.icon.Hide()
     98                 self.label.text = localization.GetByLabel('UI/Industry/NoneSelected')
     99             if self.IsInPreviewMode():
    100                 self.errorFrame.Show()
    101             else:
    102                 self.errorFrame.Hide()
    103 
    104     def GetMenu(self):
    105         if self.jobData.facility:
    106             return GetMenuService().GetMenuFromItemIDTypeID(self.jobData.facility.facilityID, self.jobData.facility.typeID)
    107 
    108     def OnMouseEnter(self):
    109         BaseFramedContainer.OnMouseEnter(self)
    110         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    111         if self.IsInPreviewMode():
    112             uicore.animations.FadeIn(self.removeIcon, duration=0.3)
    113 
    114     def OnMouseExit(self):
    115         BaseFramedContainer.OnMouseExit(self)
    116         uicore.animations.FadeOut(self.removeIcon, duration=0.3)
    117 
    118     def OnClick(self, *args):
    119         if not self.jobData:
    120             return
    121         if self.IsInPreviewMode():
    122             facilityID = self.jobData.blueprint.facilityID
    123             if facilityID:
    124                 self.jobData.facility = sm.GetService('facilitySvc').GetFacility(facilityID)
    125             else:
    126                 self.jobData.facility = None
    127             uicore.animations.FadeOut(self.removeIcon, duration=0.1)
    128         elif self.jobData.facility:
    129             sm.GetService('info').ShowInfo(self.jobData.facility.typeID, self.jobData.facility.facilityID)
    130             PlaySound(uiconst.SOUND_BUTTON_CLICK)
    131 
    132     def IsInPreviewMode(self):
    133         if not self.jobData:
    134             return False
    135         if self.jobData.facility is None:
    136             return False
    137         return self.jobData.blueprint.facilityID != self.jobData.facility.facilityID
    138 
    139     def GetHint(self):
    140         if self.IsInPreviewMode():
    141             return localization.GetByLabel('UI/Industry/PreviewModeHint')
    142 
    143     def IsFacilityChanged(self):
    144         if not self.oldJobData:
    145             return False
    146         if not self.jobData.facility or not self.oldJobData.facility:
    147             return False
    148         return self.jobData.facility.facilityID != self.oldJobData.facility.facilityID
    149 
    150 
    151 class InventorySelectionContainer(BaseFramedContainer):
    152     default_name = 'InventoryOutputContainer'
    153     CAPTION_TEXT = None
    154 
    155     def ApplyAttributes(self, attributes):
    156         BaseFramedContainer.ApplyAttributes(self, attributes)
    157         self.locationByInvID = {}
    158         labelCont = ContainerAutoSize(name='labelCont', parent=self.contentCont, align=uiconst.TOTOP, padTop=3)
    159         self.label = IndustryCaptionLabel(parent=labelCont, left=5, align=uiconst.CENTERLEFT, text=localization.GetByLabel(self.CAPTION_TEXT))
    160         self.combo = IndustryOutputCombo(parent=self.contentCont, align=uiconst.TOBOTTOM, callback=self.OnCombo, height=22)
    161         self.invController = None
    162 
    163     @telemetry.ZONE_METHOD
    164     def OnCombo(self, comboBox, key, value):
    165         invID = self.combo.GetValue()
    166         if not invID:
    167             return
    168         self.invController = invCtrl.GetInvCtrlFromInvID(invID)
    169         self.SetLocation(self.locationByInvID[invID])
    170 
    171     def UpdateState(self):
    172         if not self.jobData:
    173             return
    174         if not self.IsVisible() or not self.jobData.locations:
    175             self.Hide()
    176             return
    177         self.Show()
    178         options = []
    179         selectedInvID = None
    180         self.locationByInvID = {}
    181         locationData = self.GetInvControllersAndLocations()
    182         if not self.jobData:
    183             return
    184         for invController, location in locationData:
    185             self.locationByInvID[invController.GetInvID()] = location
    186             isContainer = isinstance(invController, invCtrl.StationContainer)
    187             indentLevel = int(isContainer)
    188             options.append((invController.GetName(),
    189              invController.GetInvID(),
    190              None,
    191              invController.GetIconName(),
    192              indentLevel))
    193             if location == self.GetLocation():
    194                 selectedInvID = invController.GetInvID()
    195                 self.invController = invController
    196 
    197         self.combo.LoadOptions(options, select=selectedInvID)
    198         if self.jobData.IsInstalled():
    199             self.combo.Disable()
    200         else:
    201             self.combo.Enable()
    202 
    203     def GetMenu(self):
    204         self.invController.GetMenu()
    205 
    206     def OnDropData(self, dragSource, dragData):
    207         self.invController.OnDropData(dragData)
    208 
    209     def OnOpenInventoryBtn(self, *args):
    210         if not self.invController:
    211             return
    212         if self.jobData.ownerID == session.corpid and session.stationid:
    213             invCtrl.StationCorpHangar().GetItems()
    214         Inventory.OpenOrShow(self.invController.GetInvID())
    215         PlaySound(uiconst.SOUND_BUTTON_CLICK)
    216 
    217     def GetLocation(self):
    218         pass
    219 
    220     def SetLocation(self):
    221         pass
    222 
    223 
    224 class InventoryOutputContainer(InventorySelectionContainer):
    225     CAPTION_TEXT = 'UI/Industry/OutputLocation'
    226 
    227     @telemetry.ZONE_METHOD
    228     def SetLocation(self, location):
    229         if self.jobData:
    230             self.jobData.outputLocation = location
    231 
    232     @telemetry.ZONE_METHOD
    233     def GetLocation(self):
    234         if self.jobData:
    235             return self.jobData.outputLocation
    236 
    237     def GetInvControllersAndLocations(self):
    238         ret = []
    239         for controller, location in super(self.__class__, self).GetInvControllersAndLocations():
    240             if not industryCommon.CheckLocationCapacity(self.jobData, location.typeID):
    241                 continue
    242             ret.append((controller, location))
    243 
    244         return ret
    245 
    246     def IsVisible(self):
    247         if not self.jobData:
    248             return False
    249         if self.jobData.status > industry.STATUS_UNSUBMITTED:
    250             return False
    251         if not self.jobData.blueprint.blueprintID:
    252             return False
    253         return True
    254 
    255 
    256 class InventoryInputContainer(InventorySelectionContainer):
    257     CAPTION_TEXT = 'UI/Industry/InputMaterialLocation'
    258 
    259     @telemetry.ZONE_METHOD
    260     def SetLocation(self, location):
    261         if self.jobData:
    262             self.jobData.inputLocation = location
    263 
    264     @telemetry.ZONE_METHOD
    265     def GetLocation(self):
    266         if self.jobData:
    267             return self.jobData.inputLocation
    268 
    269     def IsVisible(self):
    270         if not self.jobData:
    271             return False
    272         if not bool(self.jobData.materials):
    273             return False
    274         if self.jobData.status > industry.STATUS_UNSUBMITTED:
    275             return False
    276         return True
    277 
    278 
    279 class IndustryOutputCombo(Combo):
    280     default_noChoiceLabel = GetByLabel('UI/Industry/NoInventoryContainersFound')
    281     default_density = Density.COMPACT
    282 
    283     def Prepare_ActiveFrame_(self):
    284         self.sr.activeframe = Frame(name='__activeframe', parent=self, align=uiconst.TOALL, state=uiconst.UI_HIDDEN, idx=0, color=(1.0, 1.0, 1.0, 0.0))
    285 
    286     def Disable(self, *args):
    287         Combo.Disable(self, *args)
    288         self.sr.expanderParent.Hide()
    289 
    290     def Enable(self, *args):
    291         Combo.Enable(self, *args)
    292         self.sr.expanderParent.Show()