progress.py (2411B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\entries\progress.py 2 import blue 3 import localization 4 import uthread 5 from carbonui import uiconst 6 from carbonui.control.scrollentries import SE_BaseClassCore 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.fill import Fill 9 from carbonui.primitives.frame import Frame 10 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelSmall 11 12 class Progress(SE_BaseClassCore): 13 __guid__ = 'listentry.Progress' 14 __params__ = ['header', 'startTime', 'duration'] 15 16 def Startup(self, args): 17 header = EveLabelMedium(text='', parent=self, left=2, top=2, state=uiconst.UI_DISABLED) 18 p = Container(name='gauge', parent=self, width=84, height=14, left=6, top=20, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, idx=0) 19 t = EveLabelSmall(text='', parent=p, left=6, top=7, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT) 20 f = Fill(parent=p, align=uiconst.RELATIVE, width=1, height=10, left=2, top=2, color=(1.0, 1.0, 1.0, 0.25)) 21 Frame(parent=p, color=(1.0, 1.0, 1.0, 0.5)) 22 self.sr.progress = p 23 self.sr.progressFill = f 24 self.sr.progressHeader = header 25 self.sr.progressText = t 26 27 def Load(self, node): 28 self.sr.node = node 29 self.sr.progressHeader.text = node.header 30 uthread.new(self.LoadProgress) 31 32 def LoadProgress(self): 33 if not hasattr(self, 'sr'): 34 return 35 startTime = self.sr.node.startTime 36 duration = self.sr.node.duration 37 maxWidth = self.sr.progress.width - self.sr.progressFill.left * 2 38 self.sr.progress.state = uiconst.UI_DISABLED 39 while self and not self.destroyed: 40 msFromStart = max(0, blue.os.TimeDiffInMs(startTime, blue.os.GetSimTime())) 41 portion = 1.0 42 if msFromStart: 43 portion -= float(msFromStart) / duration 44 self.sr.progressFill.width = int(maxWidth * portion) 45 diff = max(0, duration - msFromStart) 46 self.sr.progressText.text = localization.GetByLabel('UI/Control/Entries/Seconds', seconds=diff / 1000.0) 47 if msFromStart > duration: 48 break 49 blue.pyos.synchro.Yield() 50 51 def GetHeight(self, *args): 52 node, width = args 53 node.height = 40 54 return node.height