careerPointsLabel.py (3717B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\careerPortal\careerPointsLabel.py 2 import uthread2 3 from carbonui import uiconst 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.uianimations import animations 6 from careergoals.client.signal import on_goal_progress_changed 7 from eve.client.script.ui import eveColor 8 from eve.client.script.ui.control.eveLabel import EveLabelMedium 9 from eveui import Sprite 10 GLYPH_ICON_SIZE = 16 11 12 class CareerPointsLabel(ContainerAutoSize): 13 default_name = 'CareerPointsLabel' 14 default_height = GLYPH_ICON_SIZE 15 default_align = uiconst.CENTER 16 17 def __init__(self, careerNode, *args, **kwargs): 18 super(CareerPointsLabel, self).__init__(*args, **kwargs) 19 self._careerNodeObject = None 20 self.currentProgress = None 21 self.pointsLabel = None 22 self.ConstructLayout() 23 if careerNode: 24 self.careerNodeObject = careerNode 25 on_goal_progress_changed.connect(self.OnGoalProgressChanged) 26 27 def Close(self): 28 on_goal_progress_changed.disconnect(self.OnGoalProgressChanged) 29 super(CareerPointsLabel, self).Close() 30 31 @property 32 def careerNodeObject(self): 33 return self._careerNodeObject 34 35 @careerNodeObject.setter 36 def careerNodeObject(self, newNodeObject): 37 self._careerNodeObject = newNodeObject 38 if not newNodeObject.goal: 39 return 40 self.currentProgress = newNodeObject.goal.progress 41 self.pointsLabel.text = self.careerNodeObject.GetCareerPathPointsText() 42 43 def ConstructLayout(self): 44 self.pointsIcon = Sprite(name='icon', parent=self, align=uiconst.TOLEFT, texturePath='res:/UI/Texture/classes/careerPortal/career_point_icon.png', width=GLYPH_ICON_SIZE) 45 self.ConstructPointsLabel() 46 47 def ConstructPointsLabel(self, text = ''): 48 if self.pointsLabel: 49 self.pointsLabel.Close() 50 self.pointsLabel = EveLabelMedium(name='label', parent=ContainerAutoSize(parent=self, align=uiconst.TOLEFT), align=uiconst.CENTERLEFT, left=4, text=text, color=eveColor.WHITE) 51 self.pointsLabel.text = text 52 53 def OnGoalProgressChanged(self, goalID, value): 54 if not value or not self.careerNodeObject or self.careerNodeObject.goal.goal_id != goalID: 55 return 56 uthread2.StartTasklet(self.AnimateProgressDifference, value - self.currentProgress) 57 self.currentProgress = value 58 59 def AnimateProgressDifference(self, difference): 60 animations.FadeOut(self, duration=0.4) 61 uthread2.Sleep(0.5) 62 self.pointsLabel.text = '+%s' % difference 63 self.pointsLabel.SetTextColor(eveColor.LEAFY_GREEN) 64 self.pointsIcon.color = eveColor.LEAFY_GREEN 65 animations.FadeIn(self, duration=0.4) 66 animations.MoveInFromBottom(self, amount=10, callback=lambda : uthread2.StartTasklet(self.MoveBack)) 67 68 def MoveBack(self): 69 uthread2.Sleep(1.0) 70 animations.MoveOutBottom(self, amount=10) 71 animations.FadeOut(self, duration=0.4) 72 uthread2.Sleep(0.5) 73 self.Reset() 74 animations.FadeIn(self, duration=0.4) 75 animations.MorphScalar(self, 'top', startVal=-10, endVal=4, duration=0.4) 76 77 def Reset(self): 78 self.pointsLabel.text = self.careerNodeObject.GetCareerPathPointsText() 79 self._UpdatePointsColor() 80 81 def _UpdatePointsColor(self): 82 progress, target = self.careerNodeObject.GetCareerPathProgress() 83 self.pointsLabel.SetTextColor(eveColor.LEAFY_GREEN if progress >= target else EveLabelMedium.default_color) 84 self.pointsIcon.color = eveColor.LEAFY_GREEN if progress >= target else eveColor.WHITE