NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

banner.py (8460B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skilltrading\banner.py
      2 import blue
      3 import evetypes
      4 import inventorycommon.typeHelpers
      5 import localization
      6 import uthread
      7 from carbonui import TextColor, uiconst
      8 from carbonui.primitives.container import Container
      9 from carbonui.primitives.containerAutoSize import ContainerAutoSize
     10 from carbonui.util.color import Color
     11 import dogma.const as dogmaConst
     12 from eve.client.script.ui.control.eveIcon import Icon
     13 from eve.client.script.ui.control.eveLabel import EveCaptionMedium, EveLabelMedium, EveLabelMediumBold
     14 from eve.client.script.ui.control.infoIcon import InfoIcon
     15 from eve.client.script.ui.control.utilButtons.marketDetailsButton import ShowMarketDetailsButton
     16 from eve.client.script.ui.shared.neocom.skillConst import COLOR_UNALLOCATED_1
     17 from eve.client.script.ui.shared.vgs.button import BuyButtonAur
     18 from eve.common.script.util.eveFormat import FmtISKAndRound
     19 from inventorycommon import const as invconst
     20 from localization.formatters.timeIntervalFormatters import FormatTimeIntervalShortWritten
     21 
     22 class SkillInjectorBanner(ContainerAutoSize):
     23 
     24     def ApplyAttributes(self, attributes):
     25         super(SkillInjectorBanner, self).ApplyAttributes(attributes)
     26         self.injectorTypeID = attributes.Get('typeID', invconst.typeSkillInjector)
     27         self.ConstructLayout()
     28         self._UpdateEstimatedInjectorPrice()
     29         self._UpdateMainText()
     30         uthread.new(self._UpdateEstimatedTimeSaved)
     31 
     32     def ConstructLayout(self):
     33         topCont = ContainerAutoSize(parent=self, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT, padTop=6)
     34         Icon(parent=topCont, align=uiconst.TOPLEFT, left=4, typeID=self.injectorTypeID, size=32, state=uiconst.UI_DISABLED)
     35         EveLabelMedium(parent=topCont, align=uiconst.TOPLEFT, left=40, text=evetypes.GetName(self.injectorTypeID))
     36         self.priceLabel = EveLabelMedium(parent=topCont, align=uiconst.TOPLEFT, top=14, left=40, color=TextColor.SECONDARY)
     37         infoBtnCont = ContainerAutoSize(parent=topCont, align=uiconst.CENTERRIGHT)
     38         InfoIcon(parent=infoBtnCont, typeID=self.injectorTypeID, align=uiconst.TOPLEFT, hint=localization.GetByLabel('UI/Commands/ShowInfo'))
     39         ShowMarketDetailsButton(parent=infoBtnCont, align=uiconst.TOPLEFT, left=24, width=16, height=16, typeID=self.injectorTypeID)
     40         self.mainLabel = EveLabelMedium(parent=self, align=uiconst.TOTOP, padding=(8, 4, 8, 4))
     41         self.estimatedTimeSavedLabel = EveLabelMedium(parent=self, align=uiconst.TOTOP, padding=(8, 4, 8, 4))
     42 
     43     def _UpdateEstimatedInjectorPrice(self):
     44         price = inventorycommon.typeHelpers.GetAveragePrice(self.injectorTypeID)
     45         if price is None or price <= 0:
     46             price = localization.GetByLabel('UI/Common/Unknown')
     47         else:
     48             price = FmtISKAndRound(price, False)
     49         text = localization.GetByLabel('UI/SkillTrading/EstimatedPrice', price=price)
     50         self.priceLabel.SetText(text)
     51 
     52     def _UpdateMainText(self):
     53         points = sm.GetService('skills').GetSkillPointAmountFromInjectors(self.injectorTypeID, quantity=1)
     54         color = Color.RGBtoHex(*COLOR_UNALLOCATED_1)
     55         text = localization.GetByLabel('UI/SkillTrading/InjectorBannerMainText', injector=self.injectorTypeID, points=points, color=color)
     56         self.mainLabel.SetText(text)
     57 
     58     def _UpdateEstimatedTimeSaved(self):
     59         points = sm.GetService('skills').GetSkillPointAmountFromInjectors(self.injectorTypeID, quantity=1)
     60         timeSaved = sm.GetService('skillqueue').GetTimeSavedByUnallocatedPoints(points)
     61         if timeSaved:
     62             timeSavedFormattedText = localization.GetByLabel('UI/SkillTrading/EstimatedTimeSaved', timeSaved=long(timeSaved), color='0xFF328FA8')
     63             self.estimatedTimeSavedLabel.SetText(timeSavedFormattedText)
     64         else:
     65             self.estimatedTimeSavedLabel.Close()
     66 
     67 
     68 class AlphaInjectorBanner(ContainerAutoSize):
     69     INJECTOR_TYPE = invconst.typeAlphaTrainingInjector
     70 
     71     def ApplyAttributes(self, attributes):
     72         super(AlphaInjectorBanner, self).ApplyAttributes(attributes)
     73         self.ConstructLayout()
     74         uthread.new(self._UpdateEstimatedInjectorPrice)
     75 
     76     def ConstructLayout(self):
     77         topCont = ContainerAutoSize(parent=self, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT, padTop=6)
     78         Icon(parent=topCont, align=uiconst.TOPLEFT, left=4, typeID=self.INJECTOR_TYPE, size=32, state=uiconst.UI_DISABLED)
     79         EveLabelMedium(parent=topCont, align=uiconst.TOPLEFT, left=40, text=evetypes.GetName(self.INJECTOR_TYPE))
     80         self.priceLabel = EveLabelMedium(parent=topCont, align=uiconst.TOPLEFT, top=14, left=40, color=TextColor.SECONDARY)
     81         infoBtnCont = ContainerAutoSize(parent=topCont, align=uiconst.CENTERRIGHT)
     82         InfoIcon(parent=infoBtnCont, typeID=self.INJECTOR_TYPE, align=uiconst.TOPLEFT, hint=localization.GetByLabel('UI/Commands/ShowInfo'))
     83         ShowMarketDetailsButton(parent=infoBtnCont, align=uiconst.TOPLEFT, left=24, width=16, height=16, typeID=self.INJECTOR_TYPE)
     84         EveLabelMedium(parent=self, align=uiconst.TOTOP, padding=(8, 4, 8, 4), text=localization.GetByLabel('UI/SkillTrading/AlphaInjectorBannerText', type=self.INJECTOR_TYPE, color=Color.RGBtoHex(*COLOR_UNALLOCATED_1), points=sm.GetService('skills').GetSkillPointAmountFromInjectors(self.INJECTOR_TYPE, quantity=1)))
     85         bottomCont = Container(parent=self, align=uiconst.TOTOP, height=50, padding=(8, 0, 8, 8))
     86         nextInjection = sm.GetService('skills').GetNextAlphaInjectionDateTime()
     87         if nextInjection > blue.os.GetWallclockTime():
     88             timerCont = ContainerAutoSize(parent=bottomCont, align=uiconst.BOTTOMLEFT, alignMode=uiconst.CENTERTOP)
     89             timerCaption = EveLabelMedium(name='timerCaption', parent=bottomCont, align=uiconst.TOPLEFT, text=localization.GetByLabel('UI/SkillTrading/NextInjectionAvailableIn'))
     90             timerCont.width = timerCaption.textwidth
     91             timerLabel = EveCaptionMedium(name='timerLabel', parent=bottomCont, align=uiconst.BOTTOMLEFT, maxWidth=180)
     92             uthread.new(self._UpdateNextInjectionTime, timerLabel, nextInjection)
     93         BuyButtonAur(parent=bottomCont, align=uiconst.BOTTOMRIGHT, top=8, types=[self.INJECTOR_TYPE])
     94 
     95     def _UpdateEstimatedInjectorPrice(self):
     96         price = inventorycommon.typeHelpers.GetAveragePrice(self.INJECTOR_TYPE)
     97         if price is None or price <= 0:
     98             price = localization.GetByLabel('UI/Common/Unknown')
     99         else:
    100             price = FmtISKAndRound(price, False)
    101         text = localization.GetByLabel('UI/SkillTrading/EstimatedPrice', price=price)
    102         self.priceLabel.SetText(text)
    103 
    104     def _UpdateNextInjectionTime(self, label, nextInjection):
    105         color = Color.RGBtoHex(*COLOR_UNALLOCATED_1)
    106         template = u'<center><color={color}>{timeLeft}</color></center>'
    107         while not label.destroyed:
    108             timeLeft = nextInjection - blue.os.GetWallclockTime()
    109             if timeLeft <= 0:
    110                 label.Close()
    111                 return
    112             text = template.format(color=color, timeLeft=FormatTimeIntervalShortWritten(timeLeft))
    113             label.SetText(text)
    114             blue.synchro.SleepWallclock(1000)
    115 
    116 
    117 class NonDiminishingInjectionBoosterBanner(ContainerAutoSize):
    118 
    119     def ApplyAttributes(self, attributes):
    120         super(NonDiminishingInjectionBoosterBanner, self).ApplyAttributes(attributes)
    121         godma = sm.GetService('godma')
    122         self.typeID = attributes.typeID
    123         self.quantity = attributes.quantity
    124         numberOfUses = godma.GetTypeAttribute(self.typeID, dogmaConst.attributeNonDiminishingSkillInjectorUses, 0)
    125         labelText = localization.GetByLabel('UI/Skills/TotalNonDiminishingInjectionsForBooster', injections=int(numberOfUses))
    126         self.content = ContainerAutoSize(parent=self, align=uiconst.CENTER, margin=(12, 8, 12, 8))
    127         self.title = EveLabelMediumBold(parent=self.content, align=uiconst.TOPLEFT, text=self.GetNameAndQuantityText())
    128         self.title.Layout()
    129         self.label = EveLabelMedium(parent=self.content, align=uiconst.TOPLEFT, width=200, text=labelText, padTop=self.title.height + 5)
    130         self.label.Layout()
    131 
    132     def GetNameAndQuantityText(self):
    133         name = evetypes.GetName(self.typeID)
    134         if self.quantity > 1:
    135             return localization.GetByLabel('UI/Inventory/QuantityAndName', quantity=self.quantity, name=name)
    136         else:
    137             return name