safeLogoffTimer.py (7321B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipHud\safeLogoffTimer.py 2 import blue 3 import localization 4 import uthread 5 from carbonui import uiconst 6 from carbonui.control.radioButton import RadioButton 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.containerAutoSize import ContainerAutoSize 9 from carbonui.primitives.frame import Frame 10 from carbonui.primitives.layoutGrid import LayoutGrid 11 from carbonui.uicore import uicore 12 from carbonui.util.color import Color 13 from eve.client.script.ui import eveColor 14 from eve.client.script.ui.control import eveLabel 15 from carbonui.control.button import Button 16 from eve.client.script.ui.control.eveLabel import EveCaptionMedium, EveCaptionLarge 17 from carbonui.decorative.menuUnderlay import MenuUnderlay 18 19 class SafeLogoffTimer(Container): 20 __guid__ = 'uicls.SafeLogoffTimer' 21 default_align = uiconst.CENTERTOP 22 default_state = uiconst.UI_NORMAL 23 default_width = 300 24 default_height = 130 25 default_top = 300 26 default_bgColor = (0.05, 0.05, 0.05, 0.75) 27 28 def ApplyAttributes(self, attributes): 29 Container.ApplyAttributes(self, attributes) 30 self.SetHint(localization.GetByLabel('UI/Inflight/SafeLogoffTimerHint')) 31 Frame(parent=self, color=(1.0, 1.0, 1.0, 0.5)) 32 self.logoffTime = attributes.logoffTime 33 topCont = Container(parent=self, align=uiconst.TOTOP, height=30) 34 timerCont = Container(parent=self, align=uiconst.TOTOP, height=70) 35 bottomCont = Container(parent=self, align=uiconst.TOALL) 36 self.caption = eveLabel.Label(parent=topCont, fontsize=24, bold=True, align=uiconst.CENTERTOP, text=localization.GetByLabel('UI/Inflight/SafeLogoffTimerCaption'), top=4) 37 self.timer = eveLabel.Label(parent=timerCont, align=uiconst.CENTER, fontsize=60, color=Color.YELLOW, bold=True) 38 self.button = Button(parent=bottomCont, label=localization.GetByLabel('UI/Inflight/SafeLogoffAbortLogoffLabel'), align=uiconst.CENTER, func=self.AbortSafeLogoff) 39 self.quitting = True 40 self.UpdateLogoffTime() 41 uthread.new(self.UpdateLogoffTime_Thread) 42 43 def UpdateLogoffTime(self): 44 timeLeft = self.logoffTime - blue.os.GetSimTime() 45 timeLeft += const.SEC 46 self.timer.text = '%.1f' % max(0.1, timeLeft / float(const.SEC)) 47 48 def UpdateLogoffTime_Thread(self): 49 self.countingDown = True 50 while self.countingDown: 51 self.UpdateLogoffTime() 52 blue.pyos.synchro.SleepSim(50) 53 54 def AbortLogoff(self, *args): 55 self.countingDown = False 56 uthread.new(self.AbortLogoff_Thread) 57 58 def AbortLogoff_Thread(self): 59 blue.pyos.synchro.SleepSim(1000) 60 uicore.animations.FadeOut(self, duration=1.0, sleep=True) 61 self.Close() 62 63 def AbortSafeLogoff(self, *args): 64 shipAccess = sm.GetService('gameui').GetShipAccess() 65 shipAccess.AbortSafeLogoff() 66 self.AbortLogoff() 67 68 def SetTimerCompleted(self): 69 self.timer.SetText('0.0') 70 self.timer.SetTextColor(Color.GREEN) 71 self.countingDown = False 72 73 def OnClose(self, *args): 74 self.countingDown = False 75 76 77 class SafeLogoffTimer2(Container): 78 __guid__ = 'uicls.SafeLogoffTimer2' 79 default_align = uiconst.CENTERTOP 80 default_state = uiconst.UI_NORMAL 81 default_width = 300 82 default_height = 225 83 default_top = 250 84 default_clipChildren = True 85 86 def ApplyAttributes(self, attributes): 87 Container.ApplyAttributes(self, attributes) 88 self.SetHint(localization.GetByLabel('UI/Inflight/SafeLogoffTimerHint')) 89 self.logoffTime = attributes.logoffTime 90 self.buttonCont = Container(name='buttonCont', parent=self, align=uiconst.TOBOTTOM, height=32, padding=(0, 16, 0, 16)) 91 self.mainGrid = LayoutGrid(name='mainGrid', parent=self, align=uiconst.CENTERTOP, columns=1, cellSpacing=(16, 16), top=16) 92 self.caption = EveCaptionMedium(parent=self.mainGrid, align=uiconst.CENTERTOP, text='<center>%s</center>' % localization.GetByLabel('UI/Inflight/SafeLogoffTimerCaption'), width=250) 93 self.timer = EveCaptionLarge(parent=self.mainGrid, align=uiconst.CENTER, color=eveColor.WARNING_ORANGE) 94 self.button = Button(parent=self.buttonCont, label=localization.GetByLabel('UI/Commands/Abort'), align=uiconst.CENTER, func=self.AbortSafeLogoff) 95 self.cleanedHouse = False 96 self.quitting = False 97 row = self.mainGrid.AddRow() 98 cbCont = ContainerAutoSize(name='cbCont', parent=row, align=uiconst.CENTERTOP) 99 self.logoffCb = RadioButton(parent=cbCont, name='logoffCb', align=uiconst.TOPLEFT, wrapLabel=False, checked=True, text=localization.GetByLabel('UI/Inflight/SafeLogoffLogOutCb'), callback=self.OnCheckboxChange, groupname='logoffCb') 100 self.quitCb = RadioButton(parent=cbCont, name='quitCb', align=uiconst.TOPLEFT, wrapLabel=False, top=32, checked=False, text=localization.GetByLabel('UI/Inflight/SafeLogoffQuitGameCb'), callback=self.OnCheckboxChange, groupname='logoffCb') 101 self.UpdateLogoffTime() 102 uthread.new(self.UpdateLogoffTime_Thread) 103 self.mainGrid.RefreshGridLayout() 104 self.RefreshHeight() 105 MenuUnderlay(bgParent=self) 106 107 def OnCheckboxChange(self, quitGameCheckbox): 108 isQuitting = self.quitCb.GetValue() 109 self.quitting = isQuitting 110 if isQuitting: 111 captionPath = 'UI/Inflight/SafeExitTimerCaption' 112 hintPath = 'UI/Inflight/SafeExitTimerHint' 113 else: 114 captionPath = 'UI/Inflight/SafeLogoffTimerCaption' 115 hintPath = 'UI/Inflight/SafeLogoffTimerHint' 116 self.caption.text = '<center>%s</center>' % localization.GetByLabel(captionPath) 117 self.SetHint(localization.GetByLabel(hintPath)) 118 119 def UpdateLogoffTime(self): 120 timeLeft = self.logoffTime - blue.os.GetSimTime() 121 timeLeft += const.SEC 122 self.timer.text = '%.1f' % max(0.1, timeLeft / float(const.SEC)) 123 self.RefreshHeight() 124 if self.cleanedHouse is False and self.quitting and timeLeft < 3 * const.SEC: 125 self.cleanedHouse = True 126 sm.ChainEvent('ProcessShutdown') 127 128 def RefreshHeight(self): 129 contentHeight = self.buttonCont.height + self.buttonCont.top + self.mainGrid.height + 6 130 if contentHeight > self.height: 131 self.height = contentHeight 132 133 def UpdateLogoffTime_Thread(self): 134 self.countingDown = True 135 while self.countingDown: 136 self.UpdateLogoffTime() 137 blue.pyos.synchro.SleepSim(50) 138 139 def AbortLogoff(self, *args): 140 self.countingDown = False 141 uthread.new(self.AbortLogoff_Thread) 142 143 def AbortLogoff_Thread(self): 144 uicore.animations.FadeTo(self, startVal=self.opacity, endVal=0.85, duration=0.1) 145 blue.pyos.synchro.SleepSim(1000) 146 uicore.animations.FadeOut(self, duration=0.5, callback=self.Close) 147 148 def AbortSafeLogoff(self, *args): 149 shipAccess = sm.GetService('gameui').GetShipAccess() 150 shipAccess.AbortSafeLogoff() 151 self.AbortLogoff() 152 153 def SetTimerCompleted(self): 154 self.timer.SetText('0.0') 155 self.timer.SetTextColor(Color.GREEN) 156 self.countingDown = False 157 158 def OnClose(self, *args): 159 self.countingDown = False