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

rollingCounter.py (3202B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\rollingCounter.py
      2 from carbonui import uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.transform import Transform
      5 from carbonui.uicore import uicore
      6 from eve.client.script.ui.control import eveLabel
      7 
      8 class RollingCounter(Container):
      9     default_width = 13
     10     default_height = 30
     11     default_callback = None
     12     default_speed = 0.5
     13     default_text = ''
     14     default_color = (1, 1, 1, 1)
     15 
     16     def ApplyAttributes(self, attributes):
     17         Container.ApplyAttributes(self, attributes)
     18         self.callback = attributes.get('callback', self.default_callback)
     19         self.speed = attributes.get('speed', self.default_speed)
     20         text = attributes.get('text', self.default_text)
     21         self.rollInColor = attributes.get('color', self.default_color)
     22         self.rollOutColor = self.rollInColor
     23         self.scrollOut = Transform(parent=self, align=uiconst.TOPLEFT, height=self.height)
     24         self.scrollOutText = eveLabel.EveCaptionLarge(text=text, parent=self.scrollOut, align=uiconst.TOLEFT, color=(1, 1, 1, 1))
     25         self.scrollIn = Transform(parent=self, align=uiconst.TOPLEFT, height=self.height)
     26         self.scrollInText = eveLabel.EveCaptionLarge(text='', parent=self.scrollIn, align=uiconst.TOLEFT, color=(1, 1, 1, 1))
     27         self.scrolling = False
     28 
     29     def RollIn(self, newText, newColor = None):
     30         if self.scrolling:
     31             return False
     32         self.scrollInText.text = newText
     33         if newColor is not None:
     34             self.rollInColor = newColor
     35             self.scrollInText.color = newColor
     36         self._RollIn()
     37         return True
     38 
     39     def _RollIn(self):
     40         if self.scrolling:
     41             return
     42         self.scrolling = True
     43         self.scrollIn.top = 0
     44         self.scrollIn.scale = (1.0, 0.0)
     45         s = 0.2
     46         uicore.animations.MorphScalar(self.scrollOut, 'top', 0, self.height - 2, self.speed, curveType=uiconst.ANIM_SMOOTH)
     47         uicore.animations.MorphVector2(self.scrollOut, 'scale', (1, 1), (1, 0), self.speed, curveType=uiconst.ANIM_SMOOTH)
     48         shadowColor = (self.rollOutColor[0] * s,
     49          self.rollOutColor[1] * s,
     50          self.rollOutColor[2] * s,
     51          0)
     52         uicore.animations.SpColorMorphTo(self.scrollOutText, self.scrollOutText.GetRGBA(), shadowColor, self.speed * 0.9, 1, uiconst.ANIM_SMOOTH)
     53         uicore.animations.MorphVector2(self.scrollIn, 'scale', (1, 0), (1, 1), self.speed, curveType=uiconst.ANIM_SMOOTH, callback=self.OnRolledIn)
     54         shadowColor = (self.rollInColor[0] * s,
     55          self.rollInColor[1] * s,
     56          self.rollInColor[2] * s,
     57          0)
     58         uicore.animations.SpColorMorphTo(self.scrollInText, shadowColor, self.rollInColor, self.speed * 0.9, 1, uiconst.ANIM_SMOOTH)
     59 
     60     def OnRolledIn(self):
     61         self.scrolling = False
     62         scrolledIn = self.scrollIn
     63         self.scrollIn = self.scrollOut
     64         self.scrollOut = scrolledIn
     65         scrolledInText = self.scrollInText
     66         self.scrollInText = self.scrollOutText
     67         self.scrollOutText = scrolledInText
     68         if self.callback is not None:
     69             self.callback(self)