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

hudReadout.py (2869B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipHud\hudReadout.py
      2 import carbonui.const as uiconst
      3 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      4 from carbonui.primitives.line import Line
      5 from eve.client.script.ui.control.eveLabel import EveLabelSmall
      6 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst
      7 from localization import GetByLabel
      8 from uihider import UiHiderMixin
      9 
     10 class HudReadout(UiHiderMixin, ContainerAutoSize):
     11     default_name = 'hudReadout'
     12     uniqueUiName = pConst.UNIQUE_NAME_HUD_READOUT
     13 
     14     def ApplyAttributes(self, attributes):
     15         self.controller = attributes.controller
     16         super(HudReadout, self).ApplyAttributes(attributes)
     17         self.shield = self._ConstructLabel('shield')
     18         self.armor = self._ConstructLabel('armor')
     19         self.structure = self._ConstructLabel('structure')
     20 
     21     def _ConstructLabel(self, refName):
     22         container = ContainerAutoSize(name=refName, parent=self, align=uiconst.TOTOP)
     23         label = EveLabelSmall(parent=container, left=2, state=uiconst.UI_DISABLED, align=uiconst.TOPRIGHT)
     24         Line(parent=container, top=6, width=-130, height=1, align=uiconst.TOPRIGHT)
     25         Line(parent=container, top=6, width=-130, height=1, align=uiconst.TOPRIGHT, color=(0.1, 0.1, 0.1, 0.5))
     26         return label
     27 
     28     def _UpdateLabelWithHpPercentage(self, labelName, hpPercentage):
     29         label = getattr(self, labelName, None)
     30         if label:
     31             label.text = GetByLabel('UI/Common/Formatting/Percentage', percentage=hpPercentage * 100)
     32 
     33     def _UpdateLabelWithHpAbsolute(self, labelName, hp, hpMax):
     34         label = getattr(self, labelName, None)
     35         if label:
     36             label.text = GetByLabel('UI/Inflight/GaugeAbsolute', left=hp, total=hpMax)
     37 
     38     def UpdateHpPercentages(self):
     39         shieldHpPercentage = self.controller.GetShieldHPPortion()
     40         armorHpPercentage = self.controller.GetArmorHPPortion()
     41         structureHpPercentage = self.controller.GetStructureHPPortion()
     42         self._UpdateLabelWithHpPercentage('shield', shieldHpPercentage)
     43         self._UpdateLabelWithHpPercentage('armor', armorHpPercentage)
     44         self._UpdateLabelWithHpPercentage('structure', structureHpPercentage)
     45 
     46     def UpdateHpAbsolutes(self):
     47         shieldHp = self.controller.GetShieldHP()
     48         armorHp = self.controller.GetArmorHP()
     49         structureHp = self.controller.GetStructureHP()
     50         shieldHpMax = self.controller.GetShieldHPMax()
     51         armorHpMax = self.controller.GetArmorHPMax()
     52         structureHpMax = self.controller.GetStructureHPMax()
     53         self._UpdateLabelWithHpAbsolute('shield', shieldHp, shieldHpMax)
     54         self._UpdateLabelWithHpAbsolute('armor', armorHp, armorHpMax)
     55         self._UpdateLabelWithHpAbsolute('structure', structureHp, structureHpMax)