main_bank_hacking_timer.py (4394B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ui\main_bank_hacking_timer.py 2 import math 3 import trinity 4 from carbonui import uiconst 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.transform import Transform 7 from carbonui.uianimations import animations 8 from carbonui.util.color import Color 9 from dynamicresources.client.ui.alert_animations import TimerDissapearAnimation, TimerAppearAnimation 10 from dynamicresources.client.ui.ess_info_panel_ui_const import TRANSITION_LOCK, MAIN_BANK_ACTIVE_BAR_COLOR 11 from eve.client.script.ui.control.gaugeCircular import GaugeCircular 12 from eveservices.menu import GetMenuService 13 from eveui import Sprite 14 15 class MainBankHackingTimer(ContainerAutoSize): 16 default_alignMode = uiconst.TOPLEFT 17 default_radius = 20 18 default_lineWidth = 5 19 default_value = 0 20 default_animate = True 21 PORTRAIT_SIZE = 28 22 23 def ApplyAttributes(self, attributes): 24 ContainerAutoSize.ApplyAttributes(self, attributes) 25 self.radius = attributes.get('radius', MainBankHackingTimer.default_radius) 26 self.lineWidth = attributes.get('lineWidth', MainBankHackingTimer.default_lineWidth) 27 self.animate = attributes.get('animate', MainBankHackingTimer.default_animate) 28 self.characterID = attributes.characterID 29 self.value = attributes.get('value', MainBankHackingTimer.default_value) 30 self.startAngle = -math.pi / 2 31 if self.animate: 32 self.ConstructLayout() 33 self.AnimateIn() 34 else: 35 self.ConstructLayout() 36 37 def AnimateIn(self): 38 self.animatedGaugeBackground = TimerAppearAnimation(parent=self, width=self.radius * 2, height=self.radius * 2, endRadius=self.radius, gaugeLineWidth=self.lineWidth, align=uiconst.TOPLEFT, timerColor=Color(*Color.WHITE).SetAlpha(0.2).GetRGBA(), left=2, top=2, transitionLock=TRANSITION_LOCK, value=0, idx=0) 39 self.ConstructPortrait() 40 41 def AnimateOut(self, sleep = False): 42 animations.FadeOut(self.linkedCharSpriteCont, duration=0.25) 43 animations.Tr2DScaleTo(self.gauge, startScale=(1, 1), endScale=(1.1, 1.1), duration=0.25, sleep=sleep) 44 animations.FadeOut(self.gauge, duration=0.25, sleep=sleep) 45 TimerDissapearAnimation(parent=self, align=uiconst.TOPLEFT, width=self.radius * 2, height=self.radius * 2, endRadius=self.radius, left=3, top=3, idx=0, transitionLock=TRANSITION_LOCK) 46 47 def ConstructLayout(self): 48 startingOpacity = 0.0 if self.animate else 1.0 49 self.gauge = GaugeCircular(parent=self, radius=self.radius + 2, lineWidth=self.lineWidth, startAngle=self.startAngle, align=uiconst.TOPLEFT, colorStart=Color(*MAIN_BANK_ACTIVE_BAR_COLOR).GetRGBA(), colorEnd=Color(*MAIN_BANK_ACTIVE_BAR_COLOR).GetRGBA(), colorBg=Color(*Color.WHITE).SetAlpha(0.2).GetRGBA(), idx=0, showMarker=False, state=uiconst.UI_DISABLED, value=0, opacity=startingOpacity) 50 self.SetValue(self.value) 51 if not self.animate: 52 self.ConstructPortrait(animate=False) 53 54 def ConstructPortrait(self, animate = True): 55 self.linkedCharSpriteCont = Transform(parent=self, align=uiconst.TOPLEFT, width=self.PORTRAIT_SIZE, height=self.PORTRAIT_SIZE, top=8, left=8, opacity=0) 56 self.smallCircleSprite = Sprite(name='smallCircleSprite', parent=self.linkedCharSpriteCont, opacity=0.0, width=self.PORTRAIT_SIZE + 3, height=self.PORTRAIT_SIZE + 3, texturePath='res:/UI/Texture/classes/ess/linkedPortraitFrame/smallCircle.png') 57 self.linkedCharacterSprite = Sprite(name='linkedCharacterSprite', parent=self.linkedCharSpriteCont, width=self.PORTRAIT_SIZE, height=self.PORTRAIT_SIZE, idx=0, textureSecondaryPath='res:/UI/Texture/classes/ess/circleMask.png', spriteEffect=trinity.TR2_SFX_MASK, state=uiconst.UI_NORMAL) 58 menuSvc = GetMenuService() 59 self.linkedCharacterSprite.GetMenu = lambda *args: menuSvc.GetMenuForOwner(self.characterID) 60 self.photoSvc = sm.StartService('photo') 61 self.photoSvc.GetPortrait(self.characterID, size=32, sprite=self.linkedCharacterSprite) 62 if animate: 63 animations.FadeIn(self.linkedCharSpriteCont, timeOffset=0.25, duration=0.25) 64 else: 65 self.linkedCharSpriteCont.opacity = 1 66 67 def SetValue(self, value): 68 self.value = value 69 self.gauge.SetValue(value)