timer_indicator.py (3006B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\battleground_capture_point_ui\client\timer_indicator.py 2 import eveui 3 import threadutils 4 from carbon.common.script.sys.serviceManager import ServiceManager 5 from carbonui import uiconst 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.fill import Fill 8 from carbonui.ui3d import InSceneContainer 9 from carbonui.uianimations import animations 10 from carbonui.uicore import uicore 11 from dynamicresources.client.ess.bracket.label import Header 12 13 class TimerIndicator(InSceneContainer): 14 15 def __init__(self, name, transform, width, height, scale, color, on_update, visible = True): 16 self._root_transform = transform 17 self._color = color 18 self._on_update = on_update 19 self._visible = visible 20 self._real_opacity = 1.0 21 scene_manager = ServiceManager.Instance().GetService('sceneManager') 22 scene = scene_manager.GetRegisteredScene('default') 23 super(TimerIndicator, self).__init__(name='{}_{}'.format(name, id(self)), state=uiconst.UI_DISABLED, scene=scene, sceneParent=scene.uiObjects, trackType=self.TRACKTYPE_TRANSFORM, parentTransform=transform, width=width, height=height, clearBackground=True, backgroundColor=(0.0, 0.0, 0.0, 0.0), renderJob=uicore.uilib.GetRenderJob(), isFullscreen=False, faceCamera=True) 24 self.scale = scale 25 self.transform.sortValueMultiplier = 0.1 26 self._opacity_wrapper = Container(parent=self, align=uiconst.TOALL, opacity=1.0 if self._visible else 0.0) 27 self._content = Container(parent=self._opacity_wrapper, align=uiconst.TOALL, opacity=self._real_opacity) 28 self._label = Header(parent=self._content, align=uiconst.CENTERLEFT, left=self.width / 2.0 + 8, top=-40) 29 Fill(parent=self._content, align=uiconst.CENTER, top=-26, width=2, height=52, color=self._color) 30 31 @property 32 def scale(self): 33 return self.transform.scaling[0] 34 35 @scale.setter 36 def scale(self, scale): 37 self.transform.scaling = (scale, scale, scale) 38 39 @property 40 def opacity(self): 41 return self._real_opacity 42 43 @opacity.setter 44 def opacity(self, opacity): 45 self._real_opacity = opacity 46 if hasattr(self, '_content'): 47 self._content.opacity = opacity 48 49 def show(self, time_offset = 0.0): 50 if not self._visible: 51 self._visible = True 52 self._start_timer_loop() 53 animations.FadeIn(self._opacity_wrapper, duration=0.3, timeOffset=time_offset) 54 55 def hide(self): 56 if self._visible: 57 self._visible = False 58 animations.BlinkOut(self._opacity_wrapper) 59 60 def set_text(self, text): 61 self._label.text = text 62 63 @threadutils.threaded 64 def _start_timer_loop(self): 65 while not self.destroyed and self._visible: 66 self._on_update(self) 67 eveui.wait_for_next_frame() 68 69 70 from dynamicresources.client.ess.bracket.debug import __reload_update__