infoPanelSkyhookTheft.py (4546B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\infoPanels\skyhookTheftUI\infoPanelSkyhookTheft.py 2 import localization 3 from carbonui import uiconst 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.control.buttonIcon import ButtonIcon 6 from eve.client.script.ui.control.eveLabel import EveCaptionSmall 7 from eve.client.script.ui.shared.infoPanels.InfoPanelBase import InfoPanelBase 8 from eve.client.script.ui.shared.infoPanels.const import infoPanelConst 9 from spacecomponents.common.components.linkWithShip import LINKSTATE_IDLE, LINKSTATE_RUNNING, LINKSTATE_DISABLED 10 from eve.client.script.ui.shared.infoPanels.skyhookTheftUI.infoPanelSkyhookTheftTimerContainer import InfoPanelSkyhookTheftTimerContainer 11 from spacecomponents.common.componentConst import SKYHOOK_REAGENT_SILO, ORBITAL_SKYHOOK 12 import eveicon 13 import logging 14 log = logging.getLogger(__name__) 15 16 class InfoPanelSkyhookTheft(InfoPanelBase): 17 default_name = 'InfoPanelSkyhookTheft' 18 panelTypeID = infoPanelConst.PANEL_SKYHOOK_THEFT 19 label = 'UI/OrbitalSkyhook/SkyhookInfoPanel/SkyhookTheftTitle' 20 default_iconTexturePath = eveicon.reagents_skyhook 21 default_isModeFixed = False 22 hasSettings = False 23 isAvailable = True 24 __notifyevents__ = InfoPanelBase.__notifyevents__ + ['OnLinkedWithShipSiloItemUpdated'] 25 26 @staticmethod 27 def IsAvailable(): 28 skyhookSvc = sm.GetService('skyhookSvc') 29 return skyhookSvc.HasOnGoingTheft() 30 31 def ApplyAttributes(self, attributes): 32 super(InfoPanelSkyhookTheft, self).ApplyAttributes(attributes) 33 self.titleCaption = EveCaptionSmall(parent=self.headerCont, text=localization.GetByLabel('UI/OrbitalSkyhook/SkyhookInfoPanel/SkyhookTheftTitle'), align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 34 self.bodyCont = ContainerAutoSize(name='bodyCont', align=uiconst.TOTOP, parent=self.mainCont) 35 self.collapsedStateCont = None 36 self.onGoingTheftItems = {} 37 self.skyhookSvc = sm.GetService('skyhookSvc') 38 self.onGoingTheft = self.skyhookSvc.GetOnGoingTheft() 39 for theft, timeValues in self.onGoingTheft.iteritems(): 40 self.CreateNewTheftTimerItem(theft, timeValues[0], timeValues[1]) 41 42 def ConstructHeaderButton(self): 43 ButtonIcon(parent=self.headerBtnCont, align=uiconst.TOPRIGHT, pos=(0, 44 0, 45 self.topCont.height, 46 self.topCont.height), texturePath=self.default_iconTexturePath, iconSize=18, showIcon=True) 47 48 def OnLinkedWithShipSiloItemUpdated(self, itemID, solarsystemID, completeAtTime, state, duration): 49 if solarsystemID != session.solarsystemid2: 50 return 51 if state in (LINKSTATE_IDLE, LINKSTATE_DISABLED): 52 theftContainer = self.onGoingTheftItems.get(itemID, None) 53 if theftContainer: 54 if completeAtTime is not None: 55 theftContainer.LinkSuccess() 56 else: 57 theftContainer.LinkFailed() 58 self.onGoingTheftItems.pop(itemID) 59 self.skyhookSvc.UpdatePanelContainer() 60 elif state == LINKSTATE_RUNNING: 61 startTime = completeAtTime - duration 62 self.CreateNewTheftTimerItem(itemID, startTime, completeAtTime) 63 64 def CreateNewTheftTimerItem(self, itemID, startTime, endTime): 65 ballpark = sm.GetService('michelle').GetBallpark() 66 siloComponent = ballpark.componentRegistry.GetComponentForItem(itemID, SKYHOOK_REAGENT_SILO) 67 skyhookComponent = ballpark.componentRegistry.GetComponentForItem(siloComponent.skyhookID, ORBITAL_SKYHOOK) 68 planetName = cfg.evelocations.Get(skyhookComponent.planetID).name 69 timerItem = InfoPanelSkyhookTheftTimerContainer(parent=self.bodyCont, name='skyhookTheftTimer', padTop=13, startTime=startTime, endTime=endTime, planetName=planetName) 70 self.onGoingTheftItems[itemID] = timerItem 71 72 def ConstructHiddenCollpsedState(self): 73 if self.collapsedStateCont and not self.collapsedStateCont.destroyed: 74 self.collapsedStateCont.Flush() 75 else: 76 self.collapsedStateCont = ContainerAutoSize(parent=self.headerCont, align=uiconst.TOLEFT) 77 if self.mode != infoPanelConst.MODE_COMPACT: 78 self.collapsedStateCont.Hide() 79 80 def ConstructCompact(self): 81 if self.collapsedStateCont: 82 self.collapsedStateCont.Show() 83 84 def ConstructNormal(self): 85 if self.collapsedStateCont: 86 self.collapsedStateCont.Hide()