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

heatGauges.py (6178B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipHud\heatGauges.py
      2 import math
      3 from carbon.common.script.util.timerstuff import AutoTimer
      4 from carbonui.primitives.container import Container
      5 import carbonui.const as uiconst
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.primitives.transform import Transform
      8 from localization import GetByLabel
      9 from carbonui.uicore import uicore
     10 LOW_HEAT_GAUGE_TEXTURES = ['res:/UI/Texture/classes/ShipUI/lowHeat_0.png',
     11  'res:/UI/Texture/classes/ShipUI/lowHeat_1.png',
     12  'res:/UI/Texture/classes/ShipUI/lowHeat_2.png',
     13  'res:/UI/Texture/classes/ShipUI/lowHeat_3.png',
     14  'res:/UI/Texture/classes/ShipUI/lowHeat_4.png']
     15 MED_HEAT_GAUGE_TEXTURES = ['res:/UI/Texture/classes/ShipUI/medHeat_0.png',
     16  'res:/UI/Texture/classes/ShipUI/medHeat_1.png',
     17  'res:/UI/Texture/classes/ShipUI/medHeat_2.png',
     18  'res:/UI/Texture/classes/ShipUI/medHeat_3.png',
     19  'res:/UI/Texture/classes/ShipUI/medHeat_4.png']
     20 HI_HEAT_GAUGE_TEXTURES = ['res:/UI/Texture/classes/ShipUI/hiHeat_0.png',
     21  'res:/UI/Texture/classes/ShipUI/hiHeat_1.png',
     22  'res:/UI/Texture/classes/ShipUI/hiHeat_2.png',
     23  'res:/UI/Texture/classes/ShipUI/hiHeat_3.png',
     24  'res:/UI/Texture/classes/ShipUI/hiHeat_4.png']
     25 ANGLE_LOW_START = -2.0
     26 ANGLE_MED_START = -62.0
     27 ANGLE_HI_START = -122.0
     28 
     29 class HeatGauges(Container):
     30     default_name = 'HeatGauges'
     31     default_state = uiconst.UI_NORMAL
     32     default_width = 160
     33     default_height = 80
     34 
     35     def ApplyAttributes(self, attributes):
     36         Container.ApplyAttributes(self, attributes)
     37         self.controller = attributes.controller
     38         self.lowHeatGauge = self.ConstructHeatGauge(ANGLE_LOW_START)
     39         self.medHeatGauge = self.ConstructHeatGauge(ANGLE_MED_START)
     40         self.hiHeatGauge = self.ConstructHeatGauge(ANGLE_HI_START)
     41         Sprite(parent=self, name='divider', pos=(56, 42, 46, 12), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/heatDivider.png')
     42         self.heatLowUnderlay = Sprite(parent=self, name='heatLowUnderlay', pos=(36, 42, 27, 38), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/lowHeat_0.png')
     43         self.heatMedUnderlay = Sprite(parent=self, name='heatMedUnderlay', pos=(57, 36, 45, 18), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/medHeat_0.png')
     44         self.heatHiUnderlay = Sprite(parent=self, name='heatHiUnderlay', pos=(95, 42, 27, 38), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/hiHeat_0.png')
     45 
     46     def ConstructHeatGauge(self, deg):
     47         miniGauge = Transform(parent=self, name='heatGauge', pos=(-1, 40, 83, 12), align=uiconst.CENTER, rotation=math.radians(deg), idx=0)
     48         Sprite(parent=miniGauge, name='needle', pos=(0, 0, 12, 12), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipUI/heatGaugeNeedle.png')
     49         return miniGauge
     50 
     51     def Update(self):
     52         self.UpdateLowHeatGauge(self.controller.GetHeatLowPortion())
     53         self.UpdateMedHeatGauge(self.controller.GetHeatMedPortion())
     54         self.UpdateHiHeatGauge(self.controller.GetHeatHiPortion())
     55 
     56     def UpdateLowHeatGauge(self, value, *args):
     57         rotation = math.radians(ANGLE_LOW_START - 56.0 * value)
     58         uicore.animations.MorphScalar(self.lowHeatGauge, 'rotation', self.lowHeatGauge.rotation, rotation, duration=0.5)
     59         textureIndex = self.GetHeatGaugeTextureIndex(value)
     60         self.heatLowUnderlay.LoadTexture(LOW_HEAT_GAUGE_TEXTURES[textureIndex])
     61 
     62     def UpdateMedHeatGauge(self, value, *args):
     63         rotation = math.radians(ANGLE_MED_START - 56.0 * value)
     64         uicore.animations.MorphScalar(self.medHeatGauge, 'rotation', self.medHeatGauge.rotation, rotation, duration=0.5)
     65         textureIndex = self.GetHeatGaugeTextureIndex(value)
     66         self.heatMedUnderlay.LoadTexture(MED_HEAT_GAUGE_TEXTURES[textureIndex])
     67 
     68     def UpdateHiHeatGauge(self, value, *args):
     69         rotation = math.radians(ANGLE_HI_START - 56.0 * value)
     70         uicore.animations.MorphScalar(self.hiHeatGauge, 'rotation', self.hiHeatGauge.rotation, rotation, duration=0.5)
     71         textureIndex = self.GetHeatGaugeTextureIndex(value)
     72         self.heatHiUnderlay.LoadTexture(HI_HEAT_GAUGE_TEXTURES[textureIndex])
     73 
     74     def GetHeatGaugeTextureIndex(self, value):
     75         if value <= 1 / 8.0:
     76             textureIndex = 0
     77         elif value <= 3 / 8.0:
     78             textureIndex = 1
     79         elif value <= 5 / 8.0:
     80             textureIndex = 2
     81         elif value <= 7 / 8.0:
     82             textureIndex = 3
     83         else:
     84             textureIndex = 4
     85         return textureIndex
     86 
     87     def LoadTooltipPanel(self, tooltipPanel, *args):
     88         tooltipPanel.LoadGeneric3ColumnTemplate()
     89         tooltipPanel.AddLabelMedium(text=GetByLabel('Tooltips/Hud/HeatStatus'), bold=True, colSpan=tooltipPanel.columns)
     90         tooltipPanel.lowHeatValue = tooltipPanel.AddLabelMedium(align=uiconst.CENTERRIGHT, cellPadding=(0, 0, 14, 0), bold=True)
     91         tooltipPanel.mediumHeatValue = tooltipPanel.AddLabelMedium(align=uiconst.CENTERRIGHT, cellPadding=(0, 0, 14, 0), bold=True)
     92         tooltipPanel.highHeatValue = tooltipPanel.AddLabelMedium(align=uiconst.CENTERRIGHT, bold=True)
     93         self._UpdateHeatTooltip(tooltipPanel)
     94         self._heatTooltipUpdate = AutoTimer(10, self._UpdateHeatTooltip, tooltipPanel)
     95 
     96     def _UpdateHeatTooltip(self, tooltipPanel):
     97         if tooltipPanel.destroyed:
     98             self._heatTooltipUpdate = None
     99             return
    100         if not self.controller.IsLoaded():
    101             self._heatTooltipUpdate = None
    102             return
    103         heatLow = self.controller.GetHeatLowPortion() * 100
    104         tooltipPanel.lowHeatValue.text = GetByLabel('Tooltips/Hud/HeatStatusLow', percentage=heatLow)
    105         heatMed = self.controller.GetHeatMedPortion() * 100
    106         tooltipPanel.mediumHeatValue.text = GetByLabel('Tooltips/Hud/HeatStatusMedium', percentage=heatMed)
    107         heatHi = self.controller.GetHeatHiPortion() * 100
    108         tooltipPanel.highHeatValue.text = GetByLabel('Tooltips/Hud/HeatStatusHigh', percentage=heatHi)