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

card.py (6841B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\systemMenu\feature_preview\card.py
      2 import eveui
      3 import localization
      4 import threadutils
      5 from carbonui import ButtonVariant, fontconst, uiconst
      6 from carbonui.control.scrollContainer import ScrollContainer
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.primitives.fill import Fill
     10 from carbonui.primitives.sprite import Sprite
     11 from eve.client.script.ui import eveColor
     12 from eve.client.script.ui.control import eveLabel
     13 from carbonui.control.button import Button
     14 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel
     15 
     16 class FeaturePreviewCard(Container):
     17     _display = False
     18     default_opacity = 0.0
     19 
     20     def __init__(self, experiment, **kwargs):
     21         self.experiment = experiment
     22         self._loading = False
     23         self._loaded = False
     24         self._content_wrap = None
     25         self._banner_wrap = None
     26         self._toggle_button = None
     27         self._restart_warning = None
     28         self._disable_message = None
     29         super(FeaturePreviewCard, self).__init__(**kwargs)
     30 
     31     def show(self):
     32         self.Show()
     33         self._load()
     34         duration = (1.0 - self.opacity) / 1.0 * 0.2
     35         eveui.fade_in(self, duration=duration)
     36 
     37     def hide(self):
     38         self.Hide()
     39 
     40     @threadutils.threaded
     41     def _load(self):
     42         if self._loaded or self._loading:
     43             return
     44         self._loading = True
     45         spinner = LoadingWheel(parent=self, align=uiconst.CENTER, opacity=0.0)
     46         eveui.fade_in(spinner, time_offset=0.5)
     47         self._content_wrap = ScrollContainer(parent=self, align=uiconst.TOALL, opacity=0.0, padding=(16, 0, 0, 0), scrollBarPadding=8)
     48         self._banner_wrap = Container(parent=self._content_wrap, align=uiconst.TOTOP, height=240, clipChildren=True)
     49         caption_cont = ContainerAutoSize(parent=self._banner_wrap, align=uiconst.TOBOTTOM, alignMode=uiconst.TOTOP, bgColor=(0.0, 0.0, 0.0, 0.75))
     50         self._toggle_button = Button(parent=ContainerAutoSize(parent=caption_cont, align=uiconst.TORIGHT, padding=16), align=uiconst.CENTER, label=self._get_toggle_button_label(), fixedheight=32, sidePadding=32, fontsize=fontconst.EVE_MEDIUM_FONTSIZE, variant=ButtonVariant.PRIMARY, func=self.experiment.toggle, args=())
     51         eveLabel.EveCaptionLarge(parent=ContainerAutoSize(parent=caption_cont, align=uiconst.TOTOP, padding=16), align=uiconst.TOTOP, text=self.experiment.title)
     52         Sprite(parent=self._banner_wrap, align=uiconst.CENTERTOP, state=uiconst.UI_DISABLED, width=1000, height=240, texturePath=self.experiment.banner)
     53         eveLabel.EveLabelMedium(parent=self._content_wrap, align=uiconst.TOTOP, top=16, text=self.experiment.description)
     54         if self.experiment.links:
     55             eveLabel.EveLabelMedium(parent=ContainerAutoSize(parent=self._content_wrap, align=uiconst.TOTOP, top=16), align=uiconst.TOTOP, state=uiconst.UI_NORMAL, text='    '.join(self.experiment.links))
     56         prerequisites = self.experiment.check_prerequisites()
     57         if prerequisites:
     58             self._toggle_button.enabled = False
     59             self._show_prerequisites_info(prerequisites)
     60         if self.experiment.requires_restart:
     61             self._show_restart_warning()
     62         eveui.fade_out(spinner, duration=0.3, on_complete=spinner.Close)
     63         eveui.fade_in(self._content_wrap, duration=0.2)
     64         self._loading = False
     65         self._loaded = True
     66         self.experiment.on_toggle.connect(self._on_toggle)
     67 
     68     def _on_toggle(self):
     69         self._toggle_button.SetLabel(self._get_toggle_button_label())
     70         if self.experiment.requires_restart:
     71             self._show_restart_warning()
     72         else:
     73             self._hide_restart_warning()
     74         if not self.experiment.is_enabled and self.experiment.disable_message:
     75             if self._disable_message is None:
     76                 self._disable_message = InfoBanner(parent=self._content_wrap, align=uiconst.TOTOP, title=localization.GetByLabel('UI/FeaturePreview/DisabledBannerHeader'), text=self.experiment.disable_message, index=self._banner_wrap.GetOrder() + 1)
     77             self._disable_message.show()
     78         elif self._disable_message is not None:
     79             self._disable_message.hide()
     80             self._disable_message = None
     81 
     82     def _get_toggle_button_label(self):
     83         if self.experiment.is_enabled:
     84             return localization.GetByLabel('UI/FeaturePreview/Disable')
     85         else:
     86             return localization.GetByLabel('UI/FeaturePreview/Enable')
     87 
     88     def _show_prerequisites_info(self, prerequisites):
     89         for prerequisite in prerequisites:
     90             InfoBanner(parent=self._content_wrap, align=uiconst.TOTOP, title=prerequisite.title, text=prerequisite.description, color=eveColor.SAND_YELLOW[:3], index=self._banner_wrap.GetOrder() + 1, hidden=False)
     91 
     92     def _show_restart_warning(self):
     93         if self._restart_warning is None:
     94             self._restart_warning = InfoBanner(parent=self._content_wrap, align=uiconst.TOTOP, title=localization.GetByLabel('UI/FeaturePreview/RestartRequiredBannerHeader'), text=localization.GetByLabel('UI/FeaturePreview/RestartRequiredBannerBody'), color=eveColor.SAND_YELLOW[:3], index=self._banner_wrap.GetOrder() + 1)
     95         self._restart_warning.show()
     96 
     97     def _hide_restart_warning(self):
     98         if self._restart_warning is not None:
     99             self._restart_warning.hide()
    100             self._restart_warning = None
    101 
    102 
    103 class InfoBanner(ContainerAutoSize):
    104 
    105     def __init__(self, parent, align, text, title = None, hidden = True, index = None, color = None):
    106         if color is None:
    107             color = eveColor.PRIMARY_BLUE[:3]
    108         self._title = title
    109         self._text = text
    110         self._color = color
    111         super(InfoBanner, self).__init__(parent=parent, align=align, opacity=0.0 if hidden else 1.0, idx=index)
    112         self._layout()
    113 
    114     def _layout(self):
    115         content_wrap = ContainerAutoSize(parent=self, align=uiconst.TOTOP, padding=16)
    116         Fill(bgParent=self, color=self._color, opacity=0.3)
    117         if self._title:
    118             eveLabel.EveLabelLargeBold(parent=content_wrap, align=uiconst.TOTOP, text=self._title, opacity=0.8)
    119         eveLabel.EveLabelMedium(parent=content_wrap, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, text=self._text, opacity=0.8)
    120 
    121     def show(self):
    122         self.GetAbsolute()
    123         self.DisableAutoSize()
    124         eveui.fade_in(self, duration=0.2, time_offset=0.1)
    125         eveui.animate(self, 'height', start_value=0, end_value=self.height, duration=0.2, on_complete=self.EnableAutoSize)
    126 
    127     def hide(self):
    128         self.DisableAutoSize()
    129         eveui.fade_out(self, duration=0.2)
    130         eveui.animate(self, 'height', end_value=0, duration=0.2, time_offset=0.1, on_complete=self.Close)