underConstructionOutputCont.py (6717B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\underConstruction\underConstructionOutputCont.py 2 import evetypes 3 import mathext 4 import trinity 5 from carbonui import const as uiconst, TextAlign, TextColor 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.layoutGrid import LayoutGrid 9 from carbonui.primitives.sprite import Sprite 10 from carbonui.primitives.vectorarc import VectorArc 11 from carbonui.uianimations import animations 12 from eve.client.script.ui import eveColor 13 from eve.client.script.ui.control.eveLabel import EveLabelLarge, EveLabelSmall 14 from eve.client.script.ui.control.gaugeCircular import GaugeCircular 15 from eve.client.script.ui.shared.underConstruction.util import GetProgressFromQty 16 from localization import GetByLabel 17 ARC_RADIUS_1 = 145 18 ARC_RADIUS_2 = 205 19 ARC_RADIUS_3 = 320 20 ARC_RADIUS_4 = 520 21 22 class UnderConstructionOutputCont(Container): 23 default_name = 'underConstructionOutputCont' 24 default_width = 400 25 default_height = 400 26 27 def ApplyAttributes(self, attributes): 28 super(UnderConstructionOutputCont, self).ApplyAttributes(attributes) 29 self.constructedTypeID = attributes.constructedTypeID 30 self._showIcon = attributes.showIcon 31 self.ConstructIcon() 32 self.ConstructLabels() 33 self.ConstructGauges() 34 self.ConstructArcs() 35 36 def ConstructIcon(self): 37 if not self._showIcon: 38 return 39 typeIcon = Sprite(parent=self, pos=(0, 0, 64, 64), align=uiconst.CENTER, state=uiconst.UI_DISABLED) 40 iconFrame = Sprite(parent=self, pos=(0, 0, 80, 80), align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/underConstruction/iconFrame.png') 41 sm.GetService('photo').GetIconByType(typeIcon, self.constructedTypeID) 42 43 def ConstructLabels(self): 44 l = EveLabelLarge(parent=self, align=uiconst.CENTER, text=evetypes.GetName(self.constructedTypeID), width=200, textAlign=TextAlign.CENTER, top=-ARC_RADIUS_1) 45 l.top = -ARC_RADIUS_1 - l.height / 2 - 10 46 parentGrid = LayoutGrid(parent=self, name='parentGrid', align=uiconst.CENTERBOTTOM, columns=1, top=10) 47 progressCont = ContainerAutoSize(parent=parentGrid, name='progressCont', align=uiconst.CENTER) 48 self.beforeProgress = EveLabelLarge(name='beforeProgress', parent=ContainerAutoSize(parent=progressCont, name='beforeProgressCont', align=uiconst.TOLEFT), align=uiconst.CENTER, text='0') 49 progressCont.height = max(self.beforeProgress.height, 16) 50 self.arrowSprite = Sprite(parent=ContainerAutoSize(parent=progressCont, name='arrowSprite', align=uiconst.TOLEFT), pos=(0, 0, 16, 16), align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/underConstruction/arrowRight.png', state=uiconst.UI_DISABLED) 51 self.afterProgress = EveLabelLarge(name='afterProgress', parent=ContainerAutoSize(parent=progressCont, name='afterProgressCont', align=uiconst.TOLEFT), align=uiconst.CENTERLEFT, text='') 52 label = EveLabelSmall(parent=parentGrid, align=uiconst.CENTERBOTTOM, text=GetByLabel('UI/Inflight/SpaceComponents/UnderConstruction/Progress'), color=TextColor.SECONDARY) 53 54 def ConstructGauges(self): 55 self.mainGauge = GaugeCircular(parent=self, name='mainGauge', colorStart=eveColor.CRYO_BLUE, colorEnd=eveColor.CRYO_BLUE, radius=145, align=uiconst.CENTER, lineWidth=7, colorBg=(0, 0, 0, 0)) 56 self.wndGauge = GaugeCircular(parent=self, name='wndGauge', colorStart=eveColor.SILVER_GREY, colorEnd=eveColor.SILVER_GREY, radius=145, align=uiconst.CENTER, lineWidth=7, colorBg=(0, 0, 0, 0)) 57 58 def ConstructArcs(self): 59 VectorArc(parent=self, align=uiconst.CENTER, radius=ARC_RADIUS_1, fill=False, lineWidth=0.5) 60 VectorArc(parent=self, align=uiconst.CENTER, radius=ARC_RADIUS_2, fill=False, lineWidth=0.32, opacity=0.5) 61 VectorArc(parent=self, align=uiconst.CENTER, radius=ARC_RADIUS_3, fill=False, lineWidth=0.25, opacity=0.5) 62 VectorArc(parent=self, align=uiconst.CENTER, radius=ARC_RADIUS_4, fill=False, lineWidth=0.2, opacity=0.5) 63 sprite = Sprite(parent=self, pos=(0, 0, 440, 440), align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/underConstruction/underConstructionLines.png', textureSecondaryPath='res:/UI/Texture/classes/DynamicItem/bgGlowRing.png', spriteEffect=trinity.TR2_SFX_MODULATE, state=uiconst.UI_DISABLED, outputMode=uiconst.OUTPUT_COLOR_AND_GLOW, opacity=0.0) 64 Sprite(parent=self, pos=(0, 0, 440, 440), align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/underConstruction/underConstructionLines.png', opacity=0.2) 65 animations.FadeTo(sprite, startVal=1.0, endVal=2.5, duration=2.6, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT) 66 animations.MorphVector2(sprite, 'scaleSecondary', startVal=(0.5, 0.5), endVal=(1.0, 1.0), duration=2.6, curveType=uiconst.ANIM_LINEAR, loops=uiconst.ANIM_REPEAT) 67 68 def UpdateProgress(self, currentQtyByTypeID, qtyByTypeIdInWnd, qtyRequiredByTypeID): 69 currentProgress = round(float(GetProgressFromQty(currentQtyByTypeID, qtyRequiredByTypeID)), 3) 70 totalRequiredQty = sum(qtyRequiredByTypeID.values()) 71 if sum(currentQtyByTypeID.values()) < totalRequiredQty: 72 currentProgress = mathext.clamp(currentProgress, 0, 0.999) 73 if qtyByTypeIdInWnd: 74 qtyByTypeIdAfterDeposit = {} 75 for typeID in qtyRequiredByTypeID: 76 afterDepositQty = currentQtyByTypeID.get(typeID, 0) + qtyByTypeIdInWnd.get(typeID, 0) 77 if afterDepositQty: 78 qtyByTypeIdAfterDeposit[typeID] = afterDepositQty 79 80 afterDepositProgress = round(float(GetProgressFromQty(qtyByTypeIdAfterDeposit, qtyRequiredByTypeID)), 3) 81 if sum(qtyByTypeIdAfterDeposit.values()) < totalRequiredQty: 82 afterDepositProgress = mathext.clamp(afterDepositProgress, 0, 0.999) 83 before = GetByLabel('UI/Common/Formatting/PercentageDecimal', percentage=100 * currentProgress) 84 after = GetByLabel('UI/Common/Formatting/PercentageDecimal', percentage=100 * afterDepositProgress) 85 else: 86 afterDepositProgress = 0 87 before = GetByLabel('UI/Common/Formatting/PercentageDecimal', percentage=100 * currentProgress) 88 after = '' 89 self.afterProgress.display = False 90 self.beforeProgress.text = before 91 self.afterProgress.text = after 92 self.afterProgress.display = bool(after) 93 self.arrowSprite.display = bool(after) 94 self.mainGauge.SetValue(currentProgress) 95 self.wndGauge.SetValue(afterDepositProgress)