ecuContainer.py (5975B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\planet\pinContainers\ecuContainer.py 2 import carbonui.const as uiconst 3 import evetypes 4 import blue 5 import localization 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from eve.client.script.ui.control.entries.generic import Generic 8 from eve.client.script.ui.control.entries.util import GetFromClass 9 from eve.client.script.ui.control.eveLabel import EveLabelMedium 10 from eve.client.script.ui.control.gauge import Gauge 11 from eve.client.script.ui.shared.planet.pinContainers.BasePinContainer import BasePinContainer, CaptionAndSubtext 12 from eve.client.script.ui.shared.planet import planetCommon 13 from eve.client.script.ui.shared.planet.surveyUI import SurveyWindow 14 import eve.common.script.planet.entities.basePin as basePin 15 from eve.common.lib import appConst as const 16 17 class ECUContainer(BasePinContainer): 18 default_name = 'ECUContainer' 19 default_height = 185 20 default_width = 300 21 INFO_CONT_HEIGHT = 80 22 panelIDs = [planetCommon.PANEL_SURVEYFORDEPOSITS, planetCommon.PANEL_PRODUCTS] + BasePinContainer.panelIDs 23 24 def _GetInfoCont(self): 25 self.currDepositTxt = CaptionAndSubtext(parent=self.infoContLeft, caption=localization.GetByLabel('UI/PI/Common/Extracting'), align=uiconst.TOTOP) 26 self.timeToDeplTxt = CaptionAndSubtext(parent=self.infoContLeft, caption=localization.GetByLabel('UI/PI/Common/TimeToDepletion'), align=uiconst.TOTOP) 27 self.currCycleGauge = Gauge(parent=self.infoContRight, value=0.0, color=planetCommon.PLANET_COLOR_CYCLE, label=localization.GetByLabel('UI/PI/Common/CurrentCycle'), cyclic=True, align=uiconst.TOTOP, padding=(0, 0, 10, 4)) 28 self.currCycleOutputTxt = CaptionAndSubtext(parent=self.infoContRight, caption=localization.GetByLabel('UI/PI/Common/CurrentCycleOutput'), align=uiconst.TOTOP) 29 30 def _UpdateInfoCont(self): 31 currentTime = blue.os.GetWallclockTime() 32 if self.pin.programType is not None and self.pin.qtyPerCycle > 0 and self.pin.expiryTime > currentTime: 33 timeToDepletion = self.pin.GetTimeToExpiry() 34 qtyRemaining = int(timeToDepletion / self.pin.GetCycleTime()) * self.pin.qtyPerCycle 35 totalTimeLeft = timeToDepletion 36 self.timeToDeplTxt.SetCaption(localization.GetByLabel('UI/PI/Common/TimeToDepletion')) 37 if totalTimeLeft < const.DAY: 38 totalTimeLeft = localization.GetByLabel('UI/PI/Common/TimeHourMinSec', time=long(totalTimeLeft)) 39 else: 40 totalTimeLeft = localization.GetByLabel('UI/PI/Common/TimeWritten', time=long(totalTimeLeft)) 41 deposName = evetypes.GetName(self.pin.programType) 42 if self.pin.activityState < basePin.STATE_IDLE: 43 currCycle = 0 44 currCycleProportion = 0.0 45 cycleTime = 0 46 currCycleOutput = localization.GetByLabel('UI/PI/Common/NoneOutput') 47 else: 48 currCycle = currentTime - self.pin.lastRunTime 49 currCycleProportion = currCycle / float(self.pin.GetCycleTime()) 50 cycleTime = self.pin.GetCycleTime() 51 currCycleOutput = localization.GetByLabel('UI/PI/Common/UnitsAmount', amount=self.pin.GetProgramOutput(blue.os.GetWallclockTime())) 52 if self.IsSomeProductUnrouted(): 53 deposName += '\n<color=red>%s</color>' % localization.GetByLabel('UI/PI/Common/NotRouted') 54 else: 55 currCycle = 0 56 totalTimeLeft = localization.GetByLabel('UI/PI/Common/TimeHourMinSec', time=0) 57 currCycleProportion = 0.0 58 cycleTime = 0 59 deposName = '<color=red>%s</color>' % localization.GetByLabel('UI/PI/Common/ProgramNotActive') 60 qtyRemaining = 0 61 currCycleOutput = localization.GetByLabel('UI/PI/Common/NoneOutput') 62 self.currDepositTxt.SetIcon(self.pin.programType) 63 self.currDepositTxt.SetSubtext(deposName) 64 if sm.GetService('planetUI').GetCurrentPlanet().IsInEditMode(): 65 self.currCycleGauge.SetSubText(localization.GetByLabel('UI/PI/Common/InactiveEditMode')) 66 self.timeToDeplTxt.SetSubtext(localization.GetByLabel('UI/PI/Common/InactiveEditMode')) 67 else: 68 self.currCycleGauge.SetValueInstantly(currCycleProportion) 69 self.timeToDeplTxt.SetSubtext(totalTimeLeft) 70 self.currCycleGauge.SetSubText(localization.GetByLabel('UI/PI/Common/CycleTimeElapsed', currTime=currCycle, totalTime=cycleTime)) 71 self.currCycleOutputTxt.SetSubtext(currCycleOutput) 72 73 def OpenSurveyWindow(self): 74 if planetCommon.PinHasBeenBuilt(self.pin.id): 75 sm.GetService('planetUI').myPinManager.EnterSurveyMode(self.pin.id) 76 self.CloseByUser() 77 return 78 cont = ContainerAutoSize(parent=self.actionCont, align=uiconst.TOTOP, padding=4) 79 EveLabelMedium(text=localization.GetByLabel('UI/PI/Common/CantSurveyInEditMode'), parent=cont, align=uiconst.TOTOP) 80 return cont 81 82 def GetStatsEntries(self): 83 scrolllist = BasePinContainer.GetStatsEntries(self) 84 if self.pin.programType is not None: 85 label = '%s<t>%s' % (localization.GetByLabel('UI/PI/Common/Extracting'), evetypes.GetName(self.pin.programType)) 86 scrolllist.append(GetFromClass(Generic, {'label': label})) 87 else: 88 label = '%s<t>%s' % (localization.GetByLabel('UI/PI/Common/Extracting'), localization.GetByLabel('UI/PI/Common/NothingExtracted')) 89 scrolllist.append(GetFromClass(Generic, {'label': label})) 90 return scrolllist 91 92 def _DecommissionSelf(self, *args): 93 if planetCommon.PinHasBeenBuilt(self.pin.id): 94 surveyWnd = SurveyWindow.GetIfOpen() 95 if surveyWnd and surveyWnd.ecuPinID == self.pin.id: 96 sm.GetService('planetUI').ExitSurveyMode() 97 BasePinContainer._DecommissionSelf(self)