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

tether.py (11810B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ess\bracket\tether.py
      2 import math
      3 import chroma
      4 import eveui
      5 import signals
      6 from carbonui import uiconst
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.fill import Fill
      9 from carbonui.primitives.sprite import Sprite
     10 from carbonui.primitives.transform import Transform
     11 from carbonui.uianimations import animations
     12 from carbonui.util.color import Color
     13 from dynamicresources.client import color
     14 
     15 class BracketTether(Container):
     16     _dot_size = 17
     17     _end_cap_size = 7
     18     _interaction_point_size = 24
     19 
     20     def __init__(self, parent = None, align = None, left = 0, top = 0, collapsed = False, on_click = None, name = None, on_close_point_click = None, width = 100):
     21         if align is None:
     22             align = self.default_align
     23         super(BracketTether, self).__init__(parent=parent, align=align, left=left, top=top, width=width, height=30, name=name or '')
     24         self._collapsed = collapsed
     25         self._locked = False
     26         self.on_click = signals.Signal()
     27         if on_click:
     28             self.on_click.connect(on_click)
     29         self.on_close_point_click = signals.Signal()
     30         if on_close_point_click:
     31             self.on_close_point_click.connect(on_close_point_click)
     32         self._construct_close_interaction_point()
     33         self._interaction_point = Container(parent=self, name='interaction_point', align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, width=self._interaction_point_size, height=self._interaction_point_size, opacity=1.0 if self._collapsed else 0.0)
     34         self._interaction_point.OnClick = self._on_interaction_point_click
     35         self._interaction_point.OnMouseEnter = self._on_interaction_point_enter
     36         self._interaction_point.OnMouseExit = self._on_interaction_point_exit
     37         if not self._collapsed:
     38             self._interaction_point.Disable()
     39         self._head_outer_segments = Transform(parent=self._interaction_point, align=uiconst.TOALL, rotationCenter=(0.5, 0.5), scalingCenter=(0.5, 0.5))
     40         self._interaction_outer_segments = Sprite(parent=self._head_outer_segments, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=18, height=18, texturePath='res:/UI/Texture/classes/ess/bracket/tether_head_outer_segments.png')
     41         animations.MorphScalar(self._head_outer_segments, 'rotation', endVal=math.pi * 2.0, duration=4.0, curveType=uiconst.ANIM_LINEAR, loops=-1)
     42         self._interaction_center_dot = Sprite(parent=self._interaction_point, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=18, height=18, texturePath='res:/UI/Texture/classes/ess/bracket/tether_head_inner.png')
     43         self._head_cont = Container(parent=self, name='head_cont', align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, left=3, width=17, height=17)
     44         self._head_inner = Sprite(parent=self._head_cont, name='_head_inner', align=uiconst.TOALL, texturePath='res:/UI/Texture/classes/ess/bracket/tether_head_inner.png', opacity=1.0 if not self._collapsed else 0.0)
     45         self._head_outer = Sprite(parent=self._head_cont, name='_head_outer', align=uiconst.TOALL, scale=(1.0, 1.0) if not self._collapsed else (2.0, 2.0), texturePath='res:/UI/Texture/classes/ess/bracket/tether_head_outer.png', opacity=1.0 if not self._collapsed else 0.0)
     46         self._stem = Fill(parent=self, align=uiconst.CENTERLEFT, left=19, height=1, width=self._stem_width if not self._collapsed else 0, color=color.white.rgb, opacity=1.0 if not self._collapsed else 0.0)
     47         self._end_cap = Sprite(parent=self, align=uiconst.CENTERRIGHT, state=uiconst.UI_DISABLED, height=self._end_cap_size if not self._collapsed else 0, width=self._end_cap_size, texturePath='res:/UI/Texture/classes/ess/bracket/tether_cap.png', opacity=1.0 if not self._collapsed else 0.0)
     48 
     49     def _construct_close_interaction_point(self):
     50         self._close_bracket_interaction_point = Container(parent=self, name='close_bracket_interaction_point', align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, width=self._interaction_point_size, height=self._interaction_point_size)
     51         if self._collapsed:
     52             self._close_bracket_interaction_point.Disable()
     53         self._close_bracket_interaction_point.OnClick = self._on_close_interaction_point_click
     54         self._close_bracket_interaction_point.OnMouseEnter = self._on_close_interaction_point_enter
     55         self._close_bracket_interaction_point.OnMouseExit = self._on_close_interaction_point_exit
     56         self._close_head_outer_segments = Transform(parent=self._close_bracket_interaction_point, align=uiconst.TOALL, rotationCenter=(0.5, 0.5), scalingCenter=(0.5, 0.5))
     57         self._close_interaction_outer_segments = Sprite(parent=self._close_head_outer_segments, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=18, height=18, texturePath='res:/UI/Texture/classes/ess/bracket/tether_head_outer_segments.png', color=Color.WHITE)
     58         self._close_bracket_interaction_point.opacity = 0.0
     59         animations.MorphScalar(self._close_interaction_outer_segments, 'rotation', endVal=math.pi * 2.0, duration=4.0, curveType=uiconst.ANIM_LINEAR, loops=-1)
     60 
     61     def _on_close_interaction_point_enter(self, *args):
     62         animations.FadeOut(self._head_outer, duration=0.2)
     63         animations.FadeIn(self._close_bracket_interaction_point, duration=0.2)
     64         animations.MorphVector2(self._close_interaction_outer_segments, 'scale', startVal=self._close_interaction_outer_segments.scale, endVal=(0.9, 0.9), duration=0.2)
     65         animations.MorphVector3(self, '_interaction_point_color', startVal=self._interaction_point_color, endVal=color.focus.rgb, duration=0.2)
     66 
     67     def _on_close_interaction_point_exit(self, *args):
     68         if not self._collapsed:
     69             animations.FadeIn(self._head_outer, duration=0.2)
     70         animations.FadeOut(self._close_bracket_interaction_point, duration=0.2)
     71         animations.MorphVector2(self._close_interaction_outer_segments, 'scale', startVal=self._close_interaction_outer_segments.scale, endVal=(1.0, 1.0), duration=0.2)
     72         animations.MorphVector3(self, '_interaction_point_color', startVal=self._interaction_point_color, endVal=color.white.rgb, duration=0.3)
     73 
     74     def _on_close_interaction_point_click(self, *args):
     75         self.on_close_point_click()
     76         eveui.Sound.button_click.play()
     77         self.ping()
     78 
     79     def _on_interaction_point_click(self, *args):
     80         self.on_click()
     81         eveui.Sound.button_click.play()
     82         self.ping()
     83 
     84     def _on_interaction_point_enter(self):
     85         animations.MorphVector2(self._head_outer_segments, 'scale', startVal=self._head_outer_segments.scale, endVal=(1.2, 1.2), duration=0.2)
     86         animations.MorphVector3(self, '_interaction_point_color', startVal=self._interaction_point_color, endVal=color.focus.rgb, duration=0.2)
     87 
     88     def _on_interaction_point_exit(self):
     89         animations.MorphVector2(self._head_outer_segments, 'scale', startVal=self._head_outer_segments.scale, endVal=(1.0, 1.0), duration=0.3)
     90         animations.MorphVector3(self, '_interaction_point_color', startVal=self._interaction_point_color, endVal=color.white.rgb, duration=0.3)
     91 
     92     def close(self):
     93         self.Close()
     94 
     95     def expand(self):
     96         if not self._collapsed:
     97             return
     98         self._locked = False
     99         self._collapsed = False
    100         self._close_bracket_interaction_point.Enable()
    101         self._interaction_point.Disable()
    102         animations.FadeOut(self._interaction_point, duration=0.1)
    103         animations.MorphVector2(self._head_outer, 'scale', startVal=(2.0, 2.0), endVal=(1.0, 1.0), duration=0.1)
    104         animations.FadeIn(self._head_inner, duration=0.1)
    105         animations.FadeIn(self._head_outer, duration=0.1)
    106         animations.FadeIn(self._stem, duration=0.2)
    107         animations.MorphScalar(self._stem, 'width', startVal=self._stem.width, endVal=self._stem_width, duration=0.2)
    108         animations.FadeIn(self._end_cap, duration=0.1, timeOffset=0.2)
    109         animations.MorphScalar(self._end_cap, 'height', startVal=self._end_cap.height, endVal=self._end_cap_size, duration=0.15, timeOffset=0.15)
    110         self._head_cont.Enable()
    111 
    112     def show_collapsed_interaction_point(self, show):
    113         if show:
    114             self._interaction_point.Enable()
    115             animations.FadeIn(self._interaction_point, duration=0.15)
    116         else:
    117             self._interaction_point.Disable()
    118             animations.FadeOut(self._interaction_point, duration=0.15)
    119 
    120     def collapse(self, lock = False):
    121         if not lock and self._locked and self._collapsed:
    122             self.show_collapsed_interaction_point(True)
    123             self._locked = False
    124             return
    125         if lock and not self._locked and self._collapsed:
    126             self.show_collapsed_interaction_point(False)
    127             self._locked = True
    128             return
    129         if self._collapsed:
    130             return
    131         self._collapsed = True
    132         self._locked = lock
    133         animations.FadeOut(self._close_bracket_interaction_point, duration=0.2)
    134         self._close_bracket_interaction_point.Disable()
    135         self._head_cont.Disable()
    136         animations.MorphScalar(self._end_cap, 'height', startVal=self._end_cap.height, endVal=0, duration=0.2)
    137         animations.FadeOut(self._end_cap, duration=0.1, timeOffset=0.1)
    138         animations.MorphScalar(self._stem, 'width', startVal=self._stem.width, endVal=0, duration=0.2, timeOffset=0.2)
    139         animations.FadeOut(self._stem, duration=0.2, timeOffset=0.2)
    140         animations.MorphVector2(self._head_outer, 'scale', startVal=(1.0, 1.0), endVal=(2.0, 2.0), duration=0.15, timeOffset=0.3)
    141         animations.FadeOut(self._head_outer, duration=0.15, timeOffset=0.3)
    142         animations.FadeOut(self._head_inner, duration=0.15, timeOffset=0.3)
    143         if not lock:
    144             self._interaction_point.Enable()
    145             animations.FadeIn(self._interaction_point, duration=0.15, timeOffset=0.3)
    146         self.ping(time_offset=0.3)
    147 
    148     def ping(self, time_offset = 0.0):
    149         ping = Sprite(parent=self._head_cont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ess/circle_256.png', width=0, height=0, opacity=0.5)
    150         animations.MorphScalar(ping, 'width', endVal=32, duration=0.3, timeOffset=time_offset)
    151         animations.MorphScalar(ping, 'height', endVal=32, duration=0.3, timeOffset=time_offset)
    152         animations.FadeOut(ping, duration=0.2, timeOffset=0.1 + time_offset, callback=ping.Close)
    153 
    154     def play_enter_animation(self):
    155         self.ping()
    156         animations.FadeTo(self._interaction_point, startVal=0.0, endVal=1.0, duration=0.2)
    157         animations.FadeTo(self._stem, startVal=0.0, endVal=1.0, duration=0.2, timeOffset=0.2)
    158         animations.MorphScalar(self._stem, 'width', startVal=0, endVal=self._stem_width, duration=0.2, timeOffset=0.2)
    159         animations.MorphScalar(self._end_cap, 'height', startVal=0, endVal=self._end_cap_size, duration=0.2, timeOffset=0.4)
    160 
    161     @property
    162     def _stem_width(self):
    163         return self.width - self._interaction_point_size + (self._interaction_point_size - self._dot_size) / 2.0
    164 
    165     @property
    166     def _interaction_point_color(self):
    167         return self._interaction_center_dot.color.GetRGB()
    168 
    169     @_interaction_point_color.setter
    170     def _interaction_point_color(self, color):
    171         rgb_color = chroma.Color.from_any(color).rgb
    172         self._interaction_center_dot.color = rgb_color
    173         self._interaction_outer_segments.color = rgb_color
    174         self._close_interaction_outer_segments.color = rgb_color
    175         self._head_inner.color = rgb_color
    176 
    177     def show_interaction_point(self):
    178         self._interaction_point.Show()
    179 
    180     def hide_interaction_point(self):
    181         self._interaction_point.Hide()
    182 
    183 
    184 from dynamicresources.client.ess.bracket.debug import __reload_update__