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

timer.py (5329B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ess\bracket\main_bank\timer.py
      2 from __future__ import division
      3 import math
      4 import chroma
      5 import datetimeutils
      6 import eveui
      7 import localization
      8 import mathext
      9 import trinity
     10 import uthread2
     11 from carbonui import uiconst
     12 from carbonui.uianimations import animations
     13 from dynamicresources.client import color
     14 from dynamicresources.client.ess.bracket.space_container import EssSpaceContainer
     15 from dynamicresources.client.ess.bracket.timer_indicator import TimerIndicator
     16 from dynamicresources.client.service import get_dynamic_resource_service
     17 from eve.client.script.ui.control.gaugeCircular import GaugeCircular
     18 
     19 class HackingTimer(object):
     20     dash_size_factor = 20.0
     21 
     22     def __init__(self, camera, ess_root_transform, link_state, radius, line_width, offset_y = 0.0, scale = 1.0):
     23         self._link_state = link_state
     24         self._radius = radius
     25         self._line_width = line_width
     26         self._offset_y = offset_y
     27         self._root_transform = ess_root_transform
     28         self._scale = scale
     29         self._camera = camera
     30         self._y_transform = trinity.EveTransform()
     31         self._y_transform.name = 'main_bank_timer'
     32         self._y_transform.translation = (0, self._offset_y, 0)
     33         self._root_transform.children.append(self._y_transform)
     34         self._space_cont = EssSpaceContainer(transform=self._y_transform, width=(self._radius + self._line_width) * 2, height=(self._radius + self._line_width) * 2, scale=scale)
     35         self._indicator_transform = trinity.EveTransform()
     36         self._y_transform.children.append(self._indicator_transform)
     37         self._indicator = TimerIndicator(name='main_bank_timer_indicator', transform=self._indicator_transform, width=512, height=512, scale=scale / 2.0, color=color.main_bank.rgba, on_update=self._on_timer_indicator_update, visible=False)
     38         self._timer = GaugeCircular(parent=self._space_cont.content, align=uiconst.CENTER, radius=self._radius, lineWidth=self._line_width, colorEnd=color.main_bank.rgba, colorStart=color.main_bank.rgba, showMarker=False, startAngle=math.pi, colorBg=chroma.Color.from_any(color.neutral).with_alpha(0.5).rgba)
     39         uthread2.start_tasklet(self._timer_update_loop)
     40         uthread2.start_tasklet(self._timer_blink_loop)
     41 
     42     @property
     43     def link_state(self):
     44         service = get_dynamic_resource_service()
     45         provider = service.ess_state_provider
     46         if provider.state.main_bank.link is not None:
     47             self._link_state = provider.state.main_bank.link
     48         return self._link_state
     49 
     50     @property
     51     def dash_count(self):
     52         return int(mathext.ceil(self.link_state.duration.total_seconds() / 60.0))
     53 
     54     def play_enter_animation(self):
     55         animations.MorphScalar(self._space_cont, 'offset_y', startVal=-1000, endVal=0, duration=0.7, curveType=uiconst.ANIM_SMOOTH)
     56         animations.FadeTo(self._space_cont, startVal=0.0, endVal=1.0, duration=0.4, timeOffset=0.3)
     57         self._indicator.show(time_offset=0.7)
     58 
     59     def play_exit_animation(self, sleep = False):
     60         self._indicator.hide()
     61         animations.BlinkOut(self._space_cont, sleep=sleep)
     62 
     63     def close(self):
     64         self._space_cont.Close()
     65         self._indicator.Close()
     66         self._root_transform.children.fremove(self._y_transform)
     67 
     68     def _timer_update_loop(self):
     69         while not self._timer.destroyed:
     70             eveui.wait_for_next_frame()
     71             progress = self.link_state.remaining.total_seconds() / self.link_state.duration.total_seconds()
     72             self._timer.value = progress
     73             angle = math.radians(mathext.lerp(0, 360, progress))
     74             radius = self._radius / (self._radius + self._line_width)
     75             self._indicator_transform.translation = (-mathext.cos(angle) * radius * self._scale / 2.0, 0, -mathext.sin(angle) * radius * self._scale / 2.0)
     76             distance = self._camera.distance_from_transform(self._indicator_transform)
     77             distance_fraction = max(distance - 10000.0, 0.0) / 100000.0
     78             self._indicator.scale = mathext.lerp(self._scale / 2.0, self._scale + 18000.0, distance_fraction)
     79             self._indicator.opacity = self._space_cont.content.opacity
     80 
     81     def _timer_blink_loop(self):
     82         while not self._timer.destroyed:
     83             if self.link_state is None:
     84                 eveui.wait_for_next_frame()
     85                 continue
     86             progress = 1.0 - self.link_state.remaining.total_seconds() / self.link_state.duration.total_seconds()
     87             if progress > 0.75:
     88                 t = (progress - 0.75) / 0.25
     89                 duration = mathext.lerp(1.0, 0.2, t)
     90                 animations.FadeTo(self._timer, startVal=1.0, endVal=0.3, duration=duration, curveType=uiconst.ANIM_WAVE, sleep=True)
     91             else:
     92                 eveui.wait_for_next_frame()
     93 
     94     def _on_timer_indicator_update(self, indicator):
     95         remaining = self.link_state.remaining
     96         filetime_remaining = datetimeutils.timedelta_to_filetime_delta(remaining)
     97         text = localization.formatters.FormatTimeIntervalShort(filetime_remaining, showFrom='minute')
     98         indicator.set_text(text)
     99         if remaining.total_seconds() <= 0.0:
    100             indicator.hide()
    101 
    102 
    103 from dynamicresources.client.ess.bracket.debug import __reload_update__