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

panePhaseStabilizerMechanics.py (7995B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panePhaseStabilizerMechanics.py
      2 import carbonui.const as uiconst
      3 from carbonui import Align
      4 from carbonui.text.styles import TextBody
      5 from carbonui.text.custom import TextCustom
      6 from carbonui.button.const import HEIGHT_NORMAL
      7 from carbonui.control.scrollContainer import ScrollContainer
      8 from carbonui.primitives.container import Container
      9 from carbonui.primitives.containerAutoSize import ContainerAutoSize
     10 from carbonui.primitives.fill import Fill
     11 from carbonui.primitives.sprite import Sprite
     12 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     13 from localization import GetByLabel
     14 from spacecomponents.client.ui.phaseStabilizer.gaugeCont import GaugeContainer
     15 from spacecomponents.common.helper import GetPhaseStabilizerAttributes
     16 
     17 class PanelPhaseStabilizerMechanics(Container):
     18 
     19     def ApplyAttributes(self, attributes):
     20         super(PanelPhaseStabilizerMechanics, self).ApplyAttributes(attributes)
     21         self.typeID = attributes.typeID
     22 
     23     def Load(self):
     24         self.Flush()
     25         self.scrollContainer = ScrollContainer(parent=self, padding=uiconst.defaultPadding)
     26         self.AddInterfaceCont()
     27         self.AddRangeLimitCont()
     28         self.AddActivationCont()
     29         self.AddPhasingProcessCont()
     30         self.AddAccessCont()
     31 
     32     def AddInterfaceCont(self):
     33         AddHeader(self.scrollContainer, GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/InterfaceHeader'))
     34         size = 100
     35         c = ContainerAutoSize(parent=self.scrollContainer, align=uiconst.TOTOP, minHeight=size, alignMode=Align.TOTOP)
     36         anchorAttributes = GetPhaseStabilizerAttributes(self.typeID)
     37         numCharges = anchorAttributes.numCharges
     38         gaugeParentCont = Container(parent=c, align=Align.TOLEFT, width=size)
     39         gaugeCont = GaugeContainer(parent=gaugeParentCont, align=uiconst.CENTERBOTTOM, pos=(0,
     40          0,
     41          size,
     42          size), size=size, activationCount=numCharges)
     43         remainingCharges = max(0, numCharges - 2)
     44         energyPercentage = 0.35
     45         gaugeCont.SetChargesRemaining(remainingCharges)
     46         gaugeCont.SetEnergy(energyPercentage)
     47         textPadLeft = 16
     48         textCont = ContainerAutoSize(parent=c, align=uiconst.TOTOP, minHeight=100, alignMode=Align.TOTOP, padLeft=textPadLeft)
     49         anchoredTextCont = ContainerAutoSize(parent=c, align=uiconst.TOBOTTOM, alignMode=Align.TOBOTTOM, padLeft=textPadLeft)
     50         activationCont = ContainerAutoSize(name='activationCont', parent=anchoredTextCont, align=uiconst.TOBOTTOM, alignMode=Align.TOBOTTOM, state=uiconst.UI_NORMAL)
     51         lineCont = Container(name='lineCont', parent=activationCont, align=uiconst.TOPLEFT, pos=(-6, 8, 2, 2))
     52         activationLabel = TextCustom(parent=activationCont, align=Align.TOBOTTOM, maxLines=1, text=GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/InterfaceActivation', numCharges=numCharges, remainingCharges=remainingCharges), fontsize=14)
     53         Sprite(parent=lineCont, align=Align.BOTTOMRIGHT, pos=(0, 0, 22, 14), texturePath='res:/UI/Texture/classes/PhaseStabilizer/legendLine2.png')
     54         energyCont = ContainerAutoSize(name='energyCont', parent=anchoredTextCont, align=uiconst.TOBOTTOM, alignMode=Align.TOBOTTOM, state=uiconst.UI_NORMAL)
     55         lineCont = Container(name='lineCont', parent=energyCont, align=uiconst.TOPLEFT, pos=(-6, 8, 2, 2))
     56         energyLabel = TextCustom(parent=energyCont, align=Align.TOBOTTOM, maxLines=1, text=GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/InterfaceEnergy', percentage=100 * energyPercentage), fontsize=14)
     57         Sprite(parent=lineCont, align=Align.BOTTOMRIGHT, pos=(0, 0, 32, 24), texturePath='res:/UI/Texture/classes/PhaseStabilizer/legendLine.png')
     58         _, activationHeight = activationLabel.MeasureTextSize(activationLabel.text)
     59         _, energyHeight = energyLabel.MeasureTextSize(energyLabel.text)
     60         textHeight = activationHeight + energyHeight + 8
     61         TextBody(parent=textCont, align=Align.TOTOP, text=GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/InterfaceText'), padBottom=textHeight, padTop=16)
     62 
     63     def AddRangeLimitCont(self):
     64         AddHeader(self.scrollContainer, GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/RangeLimitsHeader'), 8)
     65         c = Container(parent=self.scrollContainer, align=uiconst.TOTOP, height=120, padTop=8, padBottom=8)
     66         Sprite(parent=c, align=uiconst.CENTERLEFT, pos=(0, 0, 235, 120), texturePath='res:/UI/Texture/classes/PhaseStabilizer/range.png')
     67         horizontalCont = ContainerAutoSize(name='horizontalCont', parent=c, align=uiconst.VERTICALLY_CENTERED, opacity=0.8, padLeft=248)
     68         anchorAttributes = GetPhaseStabilizerAttributes(self.typeID)
     69         shipDistance = anchorAttributes.shipConnectionMaxRange / 1000
     70         anchorDistance = anchorAttributes.phaseableMaxRange / 1000
     71         text = GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/RangeLimitsTextShipAnchor', range=shipDistance)
     72         self.AddBulletin(horizontalCont, text=text, maxLines=1)
     73         text = GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/RangeLimitsTextAsteroidAnchor', range=anchorDistance)
     74         self.AddBulletin(horizontalCont, text=text, maxLines=1)
     75 
     76     def AddBulletin(self, parent, text, bulletNumber = None, maxLines = None):
     77         textCont = ContainerAutoSize(name='textCont', parent=parent, align=uiconst.TOTOP, alignMode=Align.TOTOP)
     78         padTop = 0
     79         padLeft = 16
     80         bulletLabel = TextBody(parent=textCont, padTop=padTop, text=text, align=uiconst.TOTOP, padLeft=padLeft, maxLines=maxLines)
     81         _, activationHeight = bulletLabel.MeasureTextSize(text, maxLines=1)
     82         iconSize = 8
     83         bulletinCont = Container(parent=textCont, align=uiconst.TOPLEFT, pos=(0,
     84          0,
     85          16,
     86          activationHeight))
     87         if bulletNumber:
     88             bulletLabel = TextBody(parent=bulletinCont, text='%s.' % bulletNumber, align=uiconst.CENTERLEFT)
     89         else:
     90             Sprite(parent=bulletinCont, pos=(0,
     91              padTop,
     92              iconSize,
     93              iconSize), align=Align.CENTER, texturePath='res:/ui/texture/icons/3_8_1.png', state=uiconst.UI_DISABLED)
     94 
     95     def AddActivationCont(self):
     96         text = GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/ActivationText')
     97         textList = text.splitlines(False)
     98         self.AddMultiBulletinSection(GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/ActivationHeader'), textList, showNumbers=True)
     99 
    100     def AddPhasingProcessCont(self):
    101         text = GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/PhasingProcessText')
    102         textList = text.splitlines(False)
    103         self.AddMultiBulletinSection(GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/PhasingProcessHeader'), textList)
    104 
    105     def AddAccessCont(self):
    106         text = GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/AccessAndMiningText')
    107         textList = text.splitlines(False)
    108         self.AddMultiBulletinSection(GetByLabel('UI/Inflight/SpaceComponents/PhaseStabilizer/Info/AccessAndMiningHeader'), textList)
    109 
    110     def AddMultiBulletinSection(self, headerText, textList, showNumbers = False):
    111         AddHeader(self.scrollContainer, headerText, padTop=8)
    112         c = ContainerAutoSize(name='bulletinCont', parent=self.scrollContainer, align=uiconst.TOTOP, alignMode=Align.TOTOP, padding=8)
    113         for i, text in enumerate(textList):
    114             bulletNumber = i + 1 if showNumbers else None
    115             self.AddBulletin(c, text=text, bulletNumber=bulletNumber)
    116 
    117 
    118 def AddHeader(parent, headerText, padTop = 0):
    119     c = ContainerAutoSize(name='headerCont', parent=parent, align=uiconst.TOTOP, minHeight=HEIGHT_NORMAL, padTop=padTop)
    120     EveLabelMedium(text=headerText, parent=c, left=8, top=0, state=uiconst.UI_DISABLED, maxLines=1, align=uiconst.CENTERLEFT)
    121     Fill(bgParent=c, opacity=0.05, padBottom=1)