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

progressHint.py (3455B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\careerPortal\progressHint.py
      2 import time
      3 import trinity
      4 import uthread2
      5 from carbonui import Align, uiconst
      6 from carbonui.text.styles import TextBody
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.primitives.sprite import Sprite, StreamingVideoSprite
     10 from carbonui.uianimations import animations
     11 from eve.client.script.ui import eveColor
     12 
     13 class ProgressHint(Container):
     14     default_width = 128
     15     default_height = 16
     16     ANIM_DURATION = 0.5
     17 
     18     def __init__(self, start_value, end_value, duration, offset, *args, **kwargs):
     19         super(ProgressHint, self).__init__(*args, **kwargs)
     20         self.start_value = start_value
     21         self.end_value = end_value
     22         self.current_value = 0
     23         self.duration = duration
     24         self.offset = offset
     25         self._start_time = None
     26         self._update_thread = None
     27         self.construct_layout()
     28 
     29     def Close(self):
     30         try:
     31             self.kill_update_thread()
     32         finally:
     33             super(ProgressHint, self).Close()
     34 
     35     def kill_update_thread(self):
     36         if self._update_thread is not None:
     37             self._update_thread.kill()
     38             self._update_thread = None
     39 
     40     def construct_layout(self):
     41         self.hint_container = ContainerAutoSize(name='hint_container', parent=self, align=Align.CENTER, opacity=0.0, height=16)
     42         Sprite(name='icon', parent=self.hint_container, align=Align.TOLEFT, texturePath='res:/UI/Texture/classes/careerPortal/career_point_icon.png', color=eveColor.LEAFY_GREEN, pos=(0, 0, 16, 16))
     43         label_container = ContainerAutoSize(name='label_container', parent=self.hint_container, align=Align.TOLEFT, height=16, padLeft=4)
     44         self.label = TextBody(name='label', parent=label_container, align=Align.CENTERLEFT, text='+%d.0' % self.start_value, color=eveColor.WHITE, bold=True)
     45         self.video = StreamingVideoSprite(parent=self, align=Align.CENTER, videoPath='res:/video/shared/SplashBGLoop.webm', videoLoop=True, color=eveColor.WHITE, opacity=0.0, spriteEffect=trinity.TR2_SFX_COPY, blendMode=trinity.TR2_SBM_ADD, pos=(0, 0, 256, 128))
     46         self.reveal_splash()
     47 
     48     def reveal_splash(self):
     49         animations.FadeIn(obj=self.video, endVal=1.0, duration=self.ANIM_DURATION, curveType=uiconst.ANIM_OVERSHOT5, timeOffset=self.offset, callback=self.reveal_hint)
     50 
     51     def reveal_hint(self):
     52         animations.FadeOut(self.video, duration=self.ANIM_DURATION)
     53         animations.FadeIn(obj=self.hint_container, endVal=1.0, duration=self.ANIM_DURATION, curveType=uiconst.ANIM_OVERSHOT5)
     54         self.start_update_loop()
     55 
     56     def start_update_loop(self):
     57         self.kill_update_thread()
     58         self._start_time = time.time()
     59         self._update_thread = uthread2.start_tasklet(self.update_loop)
     60         self.fade_out()
     61 
     62     def update_loop(self):
     63         while not self.destroyed:
     64             time_ratio = (time.time() - self._start_time) / max(self.duration, 0.01)
     65             value_diff = self.end_value - self.start_value
     66             current_value = min(self.start_value + value_diff * time_ratio, self.end_value)
     67             self.label.text = '+%d' % int(current_value)
     68             uthread2.Sleep(0.1)
     69 
     70     def fade_out(self):
     71         animations.FadeOut(obj=self, timeOffset=self.duration + self.ANIM_DURATION, callback=self.Close)