dailyAlphaInjectorOverlay.py (6564B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skilltrading\dailyAlphaInjectorOverlay.py 2 from carbonui import AxisAlignment, uiconst 3 from carbonui.primitives.container import Container 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.primitives.flowcontainer import FlowContainer 6 from carbonui.primitives.frame import Frame 7 from carbonui.primitives.sprite import Sprite 8 from carbonui.uianimations import animations 9 from carbonui.util.color import Color 10 from eve.client.script.ui.control import eveLabel 11 from carbonui.control.button import Button 12 from eve.client.script.ui.control.eveIcon import Icon 13 from eve.client.script.ui.control.infoIcon import InfoIcon 14 from eve.client.script.ui.control.utilButtons.marketDetailsButton import ShowMarketDetailsButton 15 from eve.client.script.ui.shared.vgs.button import BuyButtonAur 16 from eve.client.script.ui.shared.vgs.const import COLOR_PLEX 17 from eve.common.script.util.eveFormat import RoundISK 18 from inventorycommon import const as invconst 19 from inventorycommon.typeHelpers import GetAveragePrice 20 import clonegrade 21 import evetypes 22 import localization 23 24 class DailyAlphaInjectorOverlay(Container): 25 default_align = uiconst.TOALL 26 default_clipChildren = True 27 default_state = uiconst.UI_HIDDEN 28 CONTENT_LEFT = 140 29 SPLASH_LEFT = -180 30 31 def ApplyAttributes(self, attributes): 32 super(DailyAlphaInjectorOverlay, self).ApplyAttributes(attributes) 33 self.compactMode = False 34 35 def Display(self, message): 36 self.Layout() 37 self.Load(message) 38 self.Enable() 39 self.AnimShow() 40 41 def Layout(self): 42 if self.children: 43 return 44 Frame(bgParent=self, texturePath='res:/UI/Texture/classes/Monetization/vignette.png', cornerSize=150) 45 self.splash = Sprite(parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, left=self.SPLASH_LEFT, top=10, texturePath='res:/UI/Texture/classes/skilltrading/AlphaInjectorSplash.png', width=400, height=400) 46 self.content = ContainerAutoSize(parent=self, align=uiconst.CENTER, left=self.CONTENT_LEFT, width=340) 47 self.messageLabel = eveLabel.EveLabelLargeBold(parent=self.content, align=uiconst.TOTOP, color=COLOR_PLEX) 48 eveLabel.EveLabelMedium(parent=self.content, align=uiconst.TOTOP, top=12, text=localization.GetByLabel('UI/SkillTrading/AlphaInjectorOverlayMainMessage', limit=clonegrade.CLONE_STATE_ALPHA_MAX_TRAINING_SP, points=sm.GetService('skills').GetSkillPointAmountFromInjectors(invconst.typeAlphaTrainingInjector, quantity=1))) 49 itemCont = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, top=12) 50 itemIconCont = ContainerAutoSize(parent=itemCont, align=uiconst.TOLEFT, padding=(0, 8, 0, 8)) 51 Icon(parent=itemIconCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, size=64, typeID=invconst.typeAlphaTrainingInjector) 52 Sprite(parent=itemIconCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/InvItem/bgNormal.png', width=64, height=64) 53 eveLabel.EveLabelLargeBold(parent=itemCont, align=uiconst.TOTOP, padding=(8, 8, 24, 0), text=evetypes.GetName(invconst.typeAlphaTrainingInjector)) 54 infoBtnCont = ContainerAutoSize(parent=itemCont, align=uiconst.TOPRIGHT, top=8) 55 InfoIcon(parent=infoBtnCont, align=uiconst.TOPLEFT, typeID=invconst.typeAlphaTrainingInjector) 56 ShowMarketDetailsButton(parent=infoBtnCont, align=uiconst.TOPLEFT, left=24, width=16, height=16, typeID=invconst.typeAlphaTrainingInjector) 57 self.estimatePriceLabel = eveLabel.EveLabelMedium(parent=itemCont, align=uiconst.TOTOP, padding=(8, 0, 8, 6), color=Color.GRAY5) 58 buyButtonCont = FlowContainer(parent=itemCont, align=uiconst.TOTOP, padding=(8, 0, 8, 8), contentSpacing=(8, 0)) 59 BuyButtonAur(parent=buyButtonCont, align=uiconst.NOALIGN, types=[invconst.typeAlphaTrainingInjector]) 60 dismissCont = FlowContainer(parent=self.content, align=uiconst.TOTOP, padding=(8, 24, 8, 0), contentAlignment=AxisAlignment.CENTER, contentSpacing=(8, 4)) 61 Button(parent=dismissCont, align=uiconst.NOALIGN, label=localization.GetByLabel('UI/SkillQueue/MultiTrainingOverlay/Dismiss'), func=lambda *args: self.Dismiss()) 62 63 def Load(self, message): 64 self.messageLabel.SetText(message) 65 self.UpdateEstimatedPrice() 66 67 def Dismiss(self): 68 self.Disable() 69 self.AnimHide() 70 71 def UpdateEstimatedPrice(self): 72 try: 73 tokenAveragePrice = GetAveragePrice(invconst.typeAlphaTrainingInjector) 74 except KeyError: 75 tokenAveragePrice = None 76 77 if not tokenAveragePrice: 78 text = localization.GetByLabel('UI/SkillQueue/MultiTrainingOverlay/EstimatedPriceUnknown') 79 else: 80 amount = RoundISK(tokenAveragePrice) 81 text = localization.GetByLabel('UI/SkillQueue/MultiTrainingOverlay/EstimatedPrice', amount=amount) 82 self.estimatePriceLabel.SetText(text) 83 84 def AnimShow(self): 85 self.Show() 86 animations.FadeTo(self, duration=0.4) 87 if not self.compactMode: 88 animations.FadeTo(self.splash, timeOffset=0.3) 89 animations.FadeTo(self.content, timeOffset=0.3) 90 91 def AnimHide(self): 92 animations.FadeOut(self, duration=0.3, callback=self.Hide) 93 94 def EnterCompactMode(self): 95 if self.compactMode: 96 return 97 self.compactMode = True 98 animations.FadeOut(self.splash, duration=0.2) 99 animations.MorphScalar(self.splash, 'left', startVal=self.splash.left, endVal=self.SPLASH_LEFT - 60, duration=0.3) 100 animations.MorphScalar(self.content, 'left', startVal=self.content.left, endVal=0, duration=0.3) 101 102 def ExitCompactMode(self): 103 if not self.compactMode: 104 return 105 self.compactMode = False 106 animations.FadeIn(self.splash, duration=0.2) 107 animations.MorphScalar(self.splash, 'left', startVal=self.splash.left, endVal=self.SPLASH_LEFT, duration=0.3) 108 animations.MorphScalar(self.content, 'left', startVal=self.content.left, endVal=self.CONTENT_LEFT, duration=0.3) 109 110 def UpdateAlignment(self, budgetLeft = 0, budgetTop = 0, budgetWidth = 0, budgetHeight = 0, updateChildrenOnly = False): 111 if budgetWidth < 640: 112 self.EnterCompactMode() 113 else: 114 self.ExitCompactMode() 115 return super(DailyAlphaInjectorOverlay, self).UpdateAlignment(budgetLeft, budgetTop, budgetWidth, budgetHeight, updateChildrenOnly)