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

notification.py (2688B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dynamicresources\client\ess\bracket\notification.py
      2 from carbonui import uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      5 from carbonui.primitives.sprite import Sprite
      6 from carbonui.uianimations import animations
      7 from carbonui.util.color import Color
      8 from eve.client.script.ui.control import eveLabel
      9 COLOR_WARN = '#FFF47C20'
     10 COLOR_ALERT = '#FFEF3D3C'
     11 COLOR_SUCCESS = '#FF56B947'
     12 ICON_WARN = ('res:/ui/Texture/classes/ess/alertIcons/Warning_icon.png', 23, 20)
     13 ICON_ALERT = ('res:/ui/Texture/classes/ess/alertIcons/Alert_icon.png', 30, 30)
     14 ICON_SUCCESS = ('res:/ui/Texture/classes/ess/alertIcons/Success_icon.png', 18, 14)
     15 _TEXT_BACKGROUND_OPACITY = 0.8
     16 
     17 class TransitionNotification(ContainerAutoSize):
     18 
     19     def __init__(self, parent, align, text, iconHexColor, icon):
     20         super(TransitionNotification, self).__init__(parent=parent, align=align, alignMode=uiconst.TOPLEFT)
     21         iconColor = Color.HextoRGBA(iconHexColor)
     22         self.notificationText = NotificationText(self, uiconst.TOPLEFT, text, opacity=0.0, left=40, bgColor=Color.WHITE)
     23         self.iconCont = Container(parent=self, align=uiconst.TOLEFT, width=35, bgColor=iconColor)
     24         iconPath = icon[0]
     25         iconWidth = icon[1]
     26         iconHeight = icon[2]
     27         iconSprite = Sprite(parent=self.iconCont, texturePath=iconPath, width=iconWidth, height=iconHeight, align=uiconst.CENTER, top=-1)
     28         iconSprite.scalingCenter = (0.5, 0.5)
     29 
     30     def show(self, sleep = False):
     31         animations.BlinkIn(self, duration=0.1, sleep=sleep, callback=lambda : self.notificationText.show(sleep=sleep))
     32 
     33     def hide(self, close = False, sleep = False):
     34         self.iconCont.Hide()
     35         self.notificationText.hide(close=close, sleep=sleep)
     36         if close:
     37             self.Close()
     38 
     39 
     40 class NotificationText(ContainerAutoSize):
     41 
     42     def __init__(self, parent, align, text, opacity = 1.0, **kwargs):
     43         super(NotificationText, self).__init__(parent=parent, align=align, opacity=opacity, **kwargs)
     44         self._label = eveLabel.EveHeaderLarge(parent=ContainerAutoSize(parent=self, top=8, left=16, padding=(0, 0, 16, 8)), align=uiconst.TOPLEFT, text=text, color=Color.BLACK)
     45 
     46     def show(self, sleep = False):
     47         self._label.GetAbsolute()
     48         self.DisableAutoSize()
     49         animations.FadeIn(self, duration=0.2, endVal=_TEXT_BACKGROUND_OPACITY, sleep=sleep)
     50 
     51     def hide(self, close = False, sleep = False):
     52         callback = None if not close else self.Close
     53         animations.FadeOut(self, duration=0.3, callback=callback, sleep=sleep)