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

progressBar.py (4108B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\moonmining\progressBar.py
      2 from carbonui.primitives.container import Container
      3 import carbonui.const as uiconst
      4 from carbonui.primitives.fill import Fill
      5 from carbonui.primitives.frame import Frame
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.util.color import Color
      8 from eve.client.script.ui.control.eveLabel import EveLabelSmall
      9 from carbonui.uicore import uicore
     10 MINBAR_WIDTH = 0.008
     11 
     12 class ProgressBar(Container):
     13     default_name = 'progressBar'
     14     default_align = uiconst.TOTOP
     15     default_height = 60
     16 
     17     def ApplyAttributes(self, attributes):
     18         Container.ApplyAttributes(self, attributes)
     19         barHeight = attributes.barHeight
     20         color = attributes.color or (1, 1, 1, 1)
     21         text = attributes.text
     22         percentage = attributes.percentage
     23         self.leftLabel = EveLabelSmall(parent=self, text=text, align=uiconst.TOTOP)
     24         self.rightLabel = EveLabelSmall(parent=self, text='', align=uiconst.TOPRIGHT)
     25         self.barCont = Container(name='barCont', parent=self, align=uiconst.TOTOP, height=barHeight, padLeft=6, padRight=6)
     26         self.innerBarCont = Container(name='innerBarCont', parent=self.barCont, align=uiconst.TOALL)
     27         Frame(parent=self.innerBarCont, color=(0.5, 0.5, 0.5, 0.25))
     28         propWidth = max(MINBAR_WIDTH, percentage)
     29         self.propCont = Container(name='propCont', parent=self.innerBarCont, align=uiconst.TOLEFT_PROP, width=propWidth, padding=1)
     30         self.fillCont = Container(name='fillCont', parent=self.propCont, align=uiconst.TOALL, clipChildren=True)
     31         self.fill = Fill(parent=self.fillCont)
     32         self.marker = Sprite(parent=self.propCont, align=uiconst.CENTERRIGHT, texturePath='res:/UI/Texture/classes/Moonmining/inProgressMarker2.png', pos=(-4, 0, 9, 9), idx=0)
     33         self.endMarker = Sprite(parent=self.barCont, align=uiconst.CENTERRIGHT, texturePath='res:/UI/Texture/classes/Moonmining/scheduleMarker.png', pos=(-8, 0, 17, 9), idx=0)
     34         self.centerMarker = Sprite(parent=self.barCont, align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/Moonmining/scheduleMarker.png', pos=(0, 0, 17, 9), idx=0)
     35         self.centerMarker.display = False
     36         self.flashSprite = Sprite(parent=self.fillCont, align=uiconst.TOALL, texturePath='res:/UI/Texture/Classes/Industry/CenterBar/arrows.png', color=color, opacity=0.2, tileX=True)
     37         padTop = barHeight - 30 + 3
     38         dottedLine = Sprite(parent=self.innerBarCont, texturePath='res:/UI/Texture/classes/Moonmining/dottedLine.png', align=uiconst.TOALL, padTop=padTop, pos=(0, 0, 0, 0), state=uiconst.UI_DISABLED, tileX=True, tileY=True, opacity=0.25)
     39         self.ColorElement(color)
     40 
     41     def ColorElement(self, color):
     42         c = Color(*color)
     43         brightness = c.GetBrightness()
     44         fillColor = c.SetBrightness(max(brightness - 0.2, 0)).GetRGBA()
     45         fillColor = fillColor[:3] + (0.5,)
     46         self.fill.SetRGBA(*fillColor)
     47 
     48     def ChangeCenterMarkerDisplay(self, doDisplay):
     49         self.centerMarker.display = doDisplay
     50         self.endMarker.display = not doDisplay
     51         self.marker.display = not doDisplay
     52 
     53     def ChangeAnimationState(self, turnOnArrows, turnOnBlinking = True):
     54         if turnOnArrows:
     55             if not uicore.animations.IsAnimating(self.flashSprite, 'left'):
     56                 self.flashSprite.display = True
     57                 uicore.animations.MorphScalar(self.flashSprite, 'left', -120, 0, duration=4.0, curveType=uiconst.ANIM_LINEAR, loops=uiconst.ANIM_REPEAT)
     58         else:
     59             self.flashSprite.StopAnimations()
     60             self.flashSprite.display = False
     61         if turnOnBlinking:
     62             if not uicore.animations.IsAnimating(self.fill, 'opacity'):
     63                 uicore.animations.MorphScalar(self.fill, 'opacity', 0.5, 1.0, duration=1.0, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT)
     64         else:
     65             self.fill.StopAnimations()
     66             self.fill.opacity = 0.5
     67 
     68     def UpdateProgress(self, percentage):
     69         self.propCont.width = max(MINBAR_WIDTH, percentage)