animatedsprite.py (1796B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\control\animatedsprite.py 2 import carbonui.const as uiconst 3 import blue 4 import uthread 5 from carbonui.primitives.sprite import Sprite 6 7 class AnimSprite(Sprite): 8 __guid__ = 'uicls.AnimSprite' 9 default_icons = [ 'ui_1_16_%s' % (82 + i) for i in xrange(8) ] 10 default_icon = None 11 default_ignoreSize = 0 12 13 def ApplyAttributes(self, attributes): 14 self.icons = attributes.get('icons', self.default_icons) 15 attributes.icon = self.icons[0] 16 Sprite.ApplyAttributes(self, attributes) 17 icon = attributes.get('icon', self.default_icon) 18 if icon: 19 ignoreSize = attributes.get('ignoreSize', self.default_ignoreSize) 20 self.LoadIcon(icon, ignoreSize=ignoreSize) 21 onClick = attributes.get('OnClick', None) 22 if onClick: 23 self.OnClick = onClick 24 self.steps = len(self.icons) 25 self.step = 0 26 self.play = 0 27 self.playing = 0 28 29 def Loop(self): 30 while not self.destroyed: 31 self.playing = 1 32 self.state = uiconst.UI_NORMAL 33 if self.step >= self.steps: 34 self.step = 0 35 self.LoadIcon(self.icons[self.step], ignoreSize=True) 36 blue.pyos.synchro.SleepWallclock(125) 37 if self.destroyed: 38 return 39 if not self.play and self.step == 0: 40 self.state = uiconst.UI_HIDDEN 41 break 42 self.step += 1 43 44 if not self.destroyed: 45 self.playing = 0 46 47 def Stop(self): 48 self.play = 0 49 self.step = 0 50 51 def Play(self): 52 self.play = 1 53 if not self.playing: 54 self.playing = 1 55 uthread.new(self.Loop)