inProgressCont.py (7029B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\moonmining\inProgressCont.py 2 import gametime 3 from carbon.common.script.util.format import FmtDate 4 from carbon.common.script.util.timerstuff import AutoTimer 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from eve.common.lib.appConst import SEC 8 from eve.client.script.ui.control.eveLabel import EveLabelMedium, Label 9 from eve.client.script.ui.control.infoIcon import MoreInfoIcon 10 from eve.client.script.ui.control.themeColored import LineThemeColored 11 from eve.client.script.ui.moonmining import DAY_NAME_TEXT, COLOR_IN_PROGRESS, COLOR_READY, GetExtractionStage, STAGE_READY, STAGE_IN_PROGRESS, STAGE_FRACTURING, COLOR_FRACTURE 12 import blue 13 import carbonui.const as uiconst 14 from eve.client.script.ui.moonmining.outputCont import SchedulingOutputPanel 15 from eve.client.script.ui.moonmining.progressBar import ProgressBar 16 from eveservices.scheduling import GetSchedulingService 17 from localization import GetByLabel 18 from localization.formatters import FormatTimeIntervalShortWritten 19 from moonmining.const import FRACTURE_TOTAL_DURATION 20 import mathext 21 22 class InProgressCont(Container): 23 24 def ApplyAttributes(self, attributes): 25 Container.ApplyAttributes(self, attributes) 26 self.extraction = attributes.extraction 27 self.moonMaterialInfo = attributes.moonMaterialInfo 28 self.remainingUpdateThread = None 29 self.centerCont = Container(name='centerCont', parent=self, height=90, align=uiconst.TOTOP) 30 self.bottomCont = Container(name='bottomCont', parent=self, align=uiconst.TOALL) 31 self.BuildBottom() 32 self.BuildCenter() 33 34 def GetColorAndStrings(self, currentStage): 35 if currentStage == STAGE_READY: 36 return (COLOR_READY, GetByLabel('UI/Moonmining/LaserReadyToFire').upper()) 37 elif currentStage == STAGE_FRACTURING: 38 return (COLOR_FRACTURE, GetByLabel('UI/Moonmining/ExtractionFracturingStatus').upper()) 39 else: 40 year, month, wd, day, hour, min, sec, ms = blue.os.GetTimeParts(self.extraction.chunkAvailableTime) 41 dayName = DAY_NAME_TEXT[wd] 42 readyText = GetByLabel('UI/Moonmining/ExtractionScheduled', weekday=dayName[:3], timestamp=FmtDate(self.extraction.chunkAvailableTime, fmt='ss')) 43 return (COLOR_IN_PROGRESS, readyText) 44 45 def BuildCenter(self): 46 EveLabelMedium(parent=self.centerCont, text=GetByLabel('UI/Moonmining/Schedule'), align=uiconst.TOTOP) 47 LineThemeColored(parent=self.centerCont, align=uiconst.TOTOP) 48 fontSize = 14 49 self.aboveCont = ContainerAutoSize(name='aboveCont', parent=self.centerCont, height=50, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padTop=12) 50 self.traversalHelpIcon = MoreInfoIcon(parent=self.aboveCont, align=uiconst.CENTERRIGHT, hint='', padLeft=4) 51 self.traversalHelpIcon.LoadTooltipPanel = self.LoadTraversalInfoTooltipPanel 52 self.remainingLabel = Label(parent=self.aboveCont, text='', align=uiconst.TOPRIGHT, fontsize=fontSize, left=20) 53 self.scheduledAtLabel = Label(parent=self.aboveCont, text='', align=uiconst.TOTOP, fontsize=fontSize) 54 mainCenter = Container(name='mainCenter', parent=self.centerCont, align=uiconst.TOALL, padTop=8) 55 remainingText, percentage = self.GetRemainingTextAndPercentageDone(GetExtractionStage(self.extraction)) 56 self.progressBar = ProgressBar(parent=mainCenter, color=COLOR_IN_PROGRESS, percentage=percentage, barHeight=24) 57 self.UpdateRemainingTime() 58 self.remainingUpdateThread = AutoTimer(400, self.UpdateRemainingTime_thread) 59 60 def BuildBottom(self): 61 text = GetByLabel('UI/Moonmining/ProjectedOutput') 62 self.outputPanel = SchedulingOutputPanel(parent=self.bottomCont, moonMaterialInfo=self.moonMaterialInfo, top=8, outputHeaderText=text) 63 numSec = float(self.extraction.chunkAvailableTime - self.extraction.startMoveTime) / SEC 64 self.outputPanel.SetEstimation(numSec, self.extraction.yieldMultiplier) 65 66 def UpdateRemainingTime_thread(self): 67 if self.destroyed: 68 self.remainingUpdateThread = None 69 return 70 self.UpdateRemainingTime() 71 72 def UpdateRemainingTime(self): 73 currentStage = GetExtractionStage(self.extraction) 74 color, text = self.GetColorAndStrings(currentStage) 75 self.progressBar.ColorElement(color) 76 turnOnArrows = currentStage == STAGE_IN_PROGRESS 77 isLastStage = currentStage == STAGE_FRACTURING 78 if currentStage == STAGE_IN_PROGRESS: 79 self.traversalHelpIcon.display = True 80 self.remainingLabel.left = 20 81 else: 82 self.traversalHelpIcon.display = False 83 self.remainingLabel.left = 0 84 self.progressBar.ChangeAnimationState(turnOnArrows, isLastStage) 85 self.progressBar.ChangeCenterMarkerDisplay(isLastStage) 86 self.scheduledAtLabel.text = text 87 remainingText, percentage = self.GetRemainingTextAndPercentageDone(currentStage) 88 self.progressBar.UpdateProgress(percentage) 89 self.remainingLabel.text = remainingText 90 91 def GetRemainingTextAndPercentageDone(self, currentStage): 92 percentage = 1.0 93 if currentStage == STAGE_READY: 94 diff = max(0, self.extraction.naturalDecayTime - gametime.GetWallclockTime()) 95 remainingText = GetByLabel('UI/Moonmining/AutomaticFracture', countdownText=FormatTimeIntervalShortWritten(diff, showFrom='day', showTo='minute')) 96 elif currentStage == STAGE_IN_PROGRESS: 97 totalTime = self.extraction.chunkAvailableTime - self.extraction.startMoveTime 98 diff = max(0, self.extraction.chunkAvailableTime - gametime.GetWallclockTime()) 99 percentage = 1.0 - mathext.clamp(diff / float(totalTime), 0, 1.0) 100 remainingText = GetByLabel('UI/Moonmining/RemainingTime', countdownText=FormatTimeIntervalShortWritten(diff, showFrom='day', showTo='minute')) 101 elif currentStage == STAGE_FRACTURING: 102 laserFiredTimestamp = GetSchedulingService().GetLaserFiredTimestamp() or 0 103 diff = long(max(0, laserFiredTimestamp + FRACTURE_TOTAL_DURATION * SEC - gametime.GetWallclockTime())) 104 remainingText = GetByLabel('UI/Moonmining/RemainingTime', countdownText=FormatTimeIntervalShortWritten(diff, showFrom='minute', showTo='second')) 105 return (remainingText, percentage) 106 107 def UpdateUI(self): 108 self.UpdateRemainingTime() 109 110 def LoadTraversalInfoTooltipPanel(self, tooltipPanel, *args): 111 tooltipPanel.LoadGeneric1ColumnTemplate() 112 fractureDelay = long(self.extraction.naturalDecayTime - self.extraction.chunkAvailableTime) 113 text = GetByLabel('UI/Moonmining/AutomaticFractureTooltip', fractureDelay=fractureDelay) 114 tooltipPanel.AddLabelMedium(text=text, wrapWidth=200) 115 116 def Close(self): 117 self.remainingUpdateThread = None 118 Container.Close(self)