summary.py (6978B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\sov\sovHub\skyhooksCleanup\summary.py 2 import carbonui 3 import eveicon 4 from carbonui import Align, TextColor 5 from carbonui.text.styles import TextHeader, TextBody, TextDetail 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.line import Line 9 from carbonui.primitives.sprite import Sprite 10 from eve.client.script.ui import eveColor, eveThemeColor 11 from eve.client.script.ui.shared.neocom.wallet.walletUtil import HaveAccessToCorpWallet, GetDivisionName 12 from eve.common.script.util.eveFormat import FmtISK 13 from localization import GetByLabel 14 PADDING_8 = 8 15 PADDING_16 = 16 16 PADDING_32 = 32 17 18 class SovCleanupSummary(Container): 19 default_padLeft = PADDING_8 20 default_padRight = PADDING_8 21 default_clipChildren = True 22 23 def ApplyAttributes(self, attributes): 24 super(SovCleanupSummary, self).ApplyAttributes(attributes) 25 wndController = attributes.wndController 26 TextHeader(parent=self, align=Align.TOTOP, text=GetByLabel('UI/Sovereignty/SovHub/SystemCleanup/Summary'), top=PADDING_8, padBottom=PADDING_8) 27 self.acquireLine = SummaryLine(parent=self, labelPath='UI/Sovereignty/SovHub/SystemCleanup/ConvertedSkyhooks', tooltipHeaderPath='UI/Sovereignty/SovHub/SystemCleanup/ConvertedSkyhooksHintHeader', tooltipTextPath='UI/Sovereignty/SovHub/SystemCleanup/ConvertedSkyhooksHintText', cost=wndController.GetClaimFee()) 28 self.destroyLine = SummaryLine(parent=self, labelPath='UI/Sovereignty/SovHub/SystemCleanup/DestroyedSkyhooks', tooltipHeaderPath='UI/Sovereignty/SovHub/SystemCleanup/DestroyedSkyhooksHintHeader', tooltipTextPath='UI/Sovereignty/SovHub/SystemCleanup/DestroyedSkyhooksHintText') 29 self.unaffectedLine = SummaryLine(parent=self, labelPath='UI/Sovereignty/SovHub/SystemCleanup/UnaffectedSkyhooks', tooltipHeaderPath='UI/Sovereignty/SovHub/SystemCleanup/UnaffectedSkyhooksHintHeader', tooltipTextPath='UI/Sovereignty/SovHub/SystemCleanup/UnaffectedSkyhooksHintText') 30 self.ConstructTotalCost() 31 self.ConstructCorpWallet() 32 self.UpdateCost(wndController) 33 self.UpdateCorpWallet() 34 35 def ConstructTotalCost(self): 36 topCont = ContainerAutoSize(name='topCont', parent=self, align=Align.TOTOP, alignMode=Align.TOTOP, padTop=PADDING_8) 37 color = eveColor.WHITE[:3] + (0.1,) 38 leftWidth = 40 39 topLeftCont = Container(parent=topCont, bgColor=color, align=Align.TOLEFT, width=leftWidth, padRight=PADDING_8) 40 topRightCont = ContainerAutoSize(parent=topCont, align=Align.TOTOP, bgColor=color) 41 TextDetail(parent=topRightCont, text=GetByLabel('UI/Sovereignty/SovHub/SystemCleanup/TotalCost'), align=Align.CENTERRIGHT, left=PADDING_8, padTop=2, padBottom=2, bold=True, color=TextColor.SECONDARY) 42 color = eveThemeColor.THEME_FOCUSDARK[:3] + (0.6,) 43 bottomCont = ContainerAutoSize(name='bottomCont', parent=self, align=Align.TOTOP, alignMode=Align.TOTOP, padTop=PADDING_8, padBottom=PADDING_8) 44 bottomLeftCont = Container(parent=bottomCont, bgColor=color, align=Align.TOLEFT, width=leftWidth, padRight=PADDING_8) 45 Sprite(parent=bottomLeftCont, pos=(0, 0, 16, 16), texturePath=eveicon.isk, align=Align.CENTER, color=TextColor.NORMAL) 46 color = eveThemeColor.THEME_FOCUSDARK[:3] + (0.2,) 47 bottomRightCont = ContainerAutoSize(parent=bottomCont, align=Align.TOTOP, bgColor=color) 48 self.totalCost = TextHeader(parent=bottomRightCont, align=Align.CENTERRIGHT, padTop=PADDING_8, padBottom=PADDING_8, left=PADDING_8) 49 50 def ConstructCorpWallet(self): 51 Line(parent=self, top=PADDING_8) 52 corpWalletCont = ContainerAutoSize(name='corpWalletCont', parent=self, align=Align.TOTOP, alignMode=Align.TOTOP, top=PADDING_8) 53 amountCont = ContainerAutoSize(name='amountCont', parent=corpWalletCont, align=Align.TORIGHT) 54 self.corpWalletAmountLabel = TextDetail(parent=amountCont, align=Align.CENTERRIGHT, color=TextColor.SECONDARY) 55 corpWalletLabel = TextDetail(parent=corpWalletCont, text=GetByLabel('UI/Wallet/WalletWindow/CorporationWallet'), align=Align.TOTOP, color=TextColor.SECONDARY) 56 self.corpWalletDivisionLabel = TextDetail(parent=corpWalletCont, align=Align.TOTOP, color=TextColor.SECONDARY) 57 58 def UpdateCost(self, wndController): 59 maxWidth = 0 60 for textLine, func in [(self.acquireLine, wndController.GetNumAcquiringAndPrice), (self.destroyLine, wndController.GetNumDestroyingAndPrice), (self.unaffectedLine, wndController.GetNumNotAffectedAndPrice)]: 61 numSkyhooks, price = func() 62 textLine.display = bool(numSkyhooks) 63 priceWidth = textLine.UpdateText(numSkyhooks, price) 64 maxWidth = max(maxWidth, priceWidth) 65 66 for textLine in [self.acquireLine, self.destroyLine, self.unaffectedLine]: 67 textLine.SetPriceContWidth(maxWidth) 68 69 totalPrice = wndController.GetTotalPrice() 70 self.totalCost.text = FmtISK(totalPrice) 71 72 def UpdateCorpWallet(self): 73 if HaveAccessToCorpWallet() and session.corpAccountKey: 74 divisionText = GetDivisionName(session.corpAccountKey) 75 amountText = FmtISK(sm.GetService('wallet').GetCorpWealth()) 76 else: 77 divisionText = GetByLabel('UI/Generic/NotAvailableShort') 78 amountText = GetByLabel('UI/Generic/NotAvailableShort') 79 self.corpWalletAmountLabel.text = amountText 80 self.corpWalletDivisionLabel.text = divisionText 81 82 83 class SummaryLine(ContainerAutoSize): 84 default_align = Align.TOTOP 85 default_alignMode = Align.TOTOP 86 default_padTop = PADDING_8 87 default_padBottom = PADDING_8 88 default_state = carbonui.uiconst.UI_NORMAL 89 90 def ApplyAttributes(self, attributes): 91 super(SummaryLine, self).ApplyAttributes(attributes) 92 self.labelPath = attributes.labelPath 93 self.tooltipHeaderPath = attributes.tooltipHeaderPath 94 self.tooltipTextPath = attributes.tooltipTextPath 95 self.cost = attributes.cost or 0 96 self.priceCont = Container(parent=self, align=Align.TORIGHT) 97 self.priceLabel = TextBody(parent=self.priceCont, align=Align.CENTERRIGHT) 98 self.textLabel = TextBody(parent=self, align=Align.TOTOP, color=TextColor.SECONDARY) 99 100 def UpdateText(self, numSkyhooks, price): 101 self.textLabel.text = GetByLabel(self.labelPath, numSkyhooks=numSkyhooks) 102 self.priceLabel.text = FmtISK(price) 103 return self.priceLabel.width 104 105 def SetPriceContWidth(self, width): 106 self.priceCont.width = width 107 108 def LoadTooltipPanel(self, tooltipPanel, *args): 109 tooltipPanel.LoadStandardSpacing() 110 tooltipPanel.AddTextBodyLabel(text=GetByLabel(self.tooltipHeaderPath, cost=self.cost)) 111 tooltipPanel.AddTextBodyLabel(text=GetByLabel(self.tooltipTextPath), wrapWidth=300, color=TextColor.SECONDARY)