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

ramps.py (8487B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\shipModuleButton\ramps.py
      2 import math
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.sprite import Sprite
      5 from carbonui.primitives.transform import Transform
      6 import carbonui.const as uiconst
      7 import blue
      8 from carbonui.primitives.vectorlinetrace import DashedCircle
      9 import log
     10 from carbonui.uicore import uicore
     11 
     12 class ShipModuleButtonRamps(Container):
     13     default_height = 64
     14     default_width = 64
     15     default_align = uiconst.TOPLEFT
     16     default_state = uiconst.UI_DISABLED
     17     default_opacity = 0.5
     18 
     19     def ApplyAttributes(self, attributes):
     20         Container.ApplyAttributes(self, attributes)
     21         leftTexture = 'res:/UI/Texture/classes/ShipUI/slotRampLeft.png'
     22         leftRampCont = Container(parent=self, name='leftRampCont', pos=(0, 0, 32, 64), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True)
     23         self.leftRamp = Transform(parent=leftRampCont, name='leftRamp', pos=(0, 0, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
     24         rampLeftSprite = Sprite(parent=self.leftRamp, name='rampLeftSprite', pos=(0, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=leftTexture)
     25         self.leftShadowRamp = Transform(parent=leftRampCont, name='leftShadowRamp', pos=(0, 1, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_HIDDEN)
     26         shadow = Sprite(parent=self.leftShadowRamp, name='rampSprite', pos=(0, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=leftTexture, color=(0, 0, 0, 1))
     27         rightTexture = 'res:/UI/Texture/classes/ShipUI/slotRampRight.png'
     28         rightRampCont = Container(parent=self, name='rightRampCont', pos=(32, 0, 32, 64), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True)
     29         self.rightRamp = Transform(parent=rightRampCont, name='rightRamp', pos=(-32, 0, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
     30         rampRightSprite = Sprite(parent=self.rightRamp, name='rampRightSprite', pos=(32, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=rightTexture)
     31         self.rightShadowRamp = Transform(parent=rightRampCont, name='rightShadowRamp', pos=(-32, 1, 64, 64), align=uiconst.TOPLEFT, state=uiconst.UI_HIDDEN)
     32         shadow = Sprite(parent=self.rightShadowRamp, name='rampSprite', pos=(32, 0, 32, 64), state=uiconst.UI_DISABLED, texturePath=rightTexture, color=(0, 0, 0, 1))
     33         self.display = False
     34 
     35     def SetRampValues(self, portionDone):
     36         self.SetRampUpValue(portionDone)
     37         self.SetRampDownValue(portionDone)
     38 
     39     def SetRampUpValue(self, portionDone):
     40         rampUpVal = min(1.0, max(0.0, portionDone * 2))
     41         newValue = math.pi * (1 - rampUpVal)
     42         self.leftRamp.SetRotation(newValue)
     43         self.leftShadowRamp.SetRotation(newValue)
     44 
     45     def SetRampDownValue(self, portionDone):
     46         rampDownVal = min(1.0, max(0.0, portionDone * 2 - 1.0))
     47         newValue = math.pi * (1 - rampDownVal)
     48         self.rightRamp.SetRotation(newValue)
     49         self.rightShadowRamp.SetRotation(newValue)
     50         if newValue == 1.0:
     51             self.rightRamp.SetRotation(math.pi)
     52             self.rightShadowRamp.SetRotation(math.pi)
     53             self.leftRamp.SetRotation(math.pi)
     54             self.leftShadowRamp.SetRotation(math.pi)
     55 
     56     def AnimateReload(self, startTime, repairTime):
     57         self.SetRampValues(1)
     58         percentageDone = 0
     59         while self and not self.destroyed and percentageDone < 1:
     60             newNow = blue.os.GetSimTime()
     61             percentageDone = (newNow - startTime) / float(repairTime)
     62             self.SetRampValues(1 - percentageDone)
     63             self.display = True
     64             blue.pyos.synchro.Yield()
     65 
     66 
     67 class DamageStateCont(Container):
     68     size = 64
     69     default_height = size
     70     default_width = size
     71     default_top = 0
     72     default_align = uiconst.TOPLEFT
     73     default_state = uiconst.UI_HIDDEN
     74     default_opacity = 1.0
     75 
     76     def ApplyAttributes(self, attributes):
     77         Container.ApplyAttributes(self, attributes)
     78         self.isBeingRepaired = False
     79         self.endTime = None
     80         leftRampCont = Container(parent=self, name='leftRampCont', pos=(0,
     81          0,
     82          self.size / 2,
     83          self.size), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True)
     84         self.leftRamp = Sprite(parent=leftRampCont, align=uiconst.TOPLEFT, width=self.size, height=self.size, texturePath='res:\\UI\\Texture\\classes\\ShipUI\\slotDamage_Base.png', textureSecondaryPath='res:\\UI\\Texture\\classes\\PieCircle\\halfMask32.png', blendMode=1, spriteEffect=64)
     85         rightRampCont = Container(parent=self, name='rightRampCont', pos=(self.size / 2,
     86          0,
     87          self.size / 2,
     88          self.size), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True)
     89         self.rightRamp = Sprite(parent=rightRampCont, align=uiconst.TOPRIGHT, width=self.size, height=self.size, texturePath='res:\\UI\\Texture\\classes\\ShipUI\\slotDamage_Base.png', textureSecondaryPath='res:\\UI\\Texture\\classes\\PieCircle\\halfMask32.png', blendMode=1, spriteEffect=64)
     90 
     91     def SetLeftRampValue(self, hpPercentage):
     92         hpPercentage = min(1.0, max(0.5, hpPercentage))
     93         self.leftRamp.rotationSecondary = -0.8 * (2 * hpPercentage - 1) * math.pi
     94 
     95     def SetRightRampValue(self, hpPercentage):
     96         hpPercentage = max(0, min(0.5, hpPercentage))
     97         self.rightRamp.rotationSecondary = 0.8 * (1 - 2 * hpPercentage) * math.pi
     98 
     99     def SetRampValues(self, hpPercentage):
    100         self.leftRamp.spriteEffect = 64
    101         self.rightRamp.spriteEffect = 64
    102         self.SetLeftRampValue(hpPercentage)
    103         self.SetRightRampValue(hpPercentage)
    104 
    105     def SetDamage(self, damage):
    106         imageIndex = max(1, int(damage * 8))
    107         texturePath = 'res:/UI/Texture/classes/ShipUI/slotDamage_%s.png' % imageIndex
    108         self.leftRamp.SetTexturePath(texturePath)
    109         self.rightRamp.SetTexturePath(texturePath)
    110         self.leftRamp.spriteEffect = 32
    111         self.rightRamp.spriteEffect = 32
    112 
    113     def Blink(self, damageAmount):
    114         for ramp in (self.rightRamp, self.leftRamp):
    115             sm.GetService('ui').BlinkSpriteA(ramp, 1.0, 2000 - 1000 * damageAmount, 2, passColor=0)
    116 
    117     def AnimateRepair(self, dmg, hp, repairTime, startTime):
    118         if not repairTime:
    119             return
    120         self.isBeingRepaired = True
    121         self.endTime = repairTime + startTime
    122         while self and not self.destroyed and self.isBeingRepaired:
    123             newNow = blue.os.GetSimTime()
    124             percentageDone = (newNow - startTime) / float(repairTime)
    125             damageLeft = 1 - percentageDone
    126             hpPercentage = (hp - dmg * damageLeft) / hp
    127             self.SetRampValues(hpPercentage)
    128             blue.pyos.synchro.Yield()
    129 
    130         self.endTime = None
    131 
    132     def StopRepair(self):
    133         self.isBeingRepaired = False
    134 
    135 
    136 class ShipModuleReactivationTimer(Container):
    137     default_height = 50
    138     default_width = 50
    139     default_align = uiconst.CENTER
    140     default_state = uiconst.UI_DISABLED
    141 
    142     def ApplyAttributes(self, attributes):
    143         Container.ApplyAttributes(self, attributes)
    144         size = self.width
    145         if self.width != self.height:
    146             log.LogTraceback("ShipModuleReactivationTimer don't have width and height as the same value")
    147         maskSize = round(size * 1.28)
    148         Sprite(parent=self, name='maskSprite', align=uiconst.CENTER, pos=(0,
    149          0,
    150          maskSize,
    151          maskSize), texturePath='res:/UI/Texture/classes/ShipUI/slotSolidBackground.png', color=(0, 0, 0, 1))
    152         gaugeRadius = self.height / 2 - 3
    153         self.gauge = DashedCircle(parent=self, dashCount=18, dashSizeFactor=4.0, range=math.pi * 2, lineWidth=6, radius=gaugeRadius, startAngle=math.pi / 2, startColor=(1, 1, 1, 0.3), endColor=(1, 1, 1, 0.3))
    154         self.endTime = None
    155 
    156     def AnimateTimer(self, startTime, repairTime):
    157         percentageDone = 0
    158         self.end = 1
    159         self.endTime = startTime + repairTime
    160         uicore.animations.MorphScalar(self.gauge, 'opacity', startVal=1.0, endVal=0.6, duration=1.5, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_BOUNCE)
    161         while self and not self.destroyed and percentageDone < 1:
    162             newNow = blue.os.GetSimTime()
    163             percentageDone = (newNow - startTime) / float(repairTime)
    164             self.gauge.end = 1 - percentageDone
    165             self.display = True
    166             blue.pyos.synchro.Yield()
    167 
    168         self.endTime = None
    169         self.gauge.StopAnimations()