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

neocomButton.py (3210B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\omega\upsell\neocomButton.py
      2 import uthread2
      3 from eve.client.script.ui.omega.upsell.omegaUpsellWindow import OmegaUpsellWindow
      4 from eve.client.script.ui.shared.neocom.neocom import neocomConst
      5 from eve.client.script.ui.shared.neocom.neocom.btnData.btnDataNode import BtnDataNode
      6 from eve.client.script.ui.shared.neocom.neocom.buttons.const import UPSELL_FIXED_ANALYTIC_ID
      7 from eve.client.script.ui.shared.neocom.neocom.fixedButtonExtension import FixedButtonExtension, SortPriority
      8 from localization import GetByLabel
      9 from neocom2 import btnIDs
     10 from omega.client.clone_grade_svc import get_clone_grade_svc
     11 from stackless_response_router.exceptions import TimeoutException
     12 import omega.client.signal as omega_signals
     13 
     14 class OmegaUpsellFixedNeocomButtonExtension(FixedButtonExtension):
     15     sort_priority = SortPriority.OMEGA_UPSELL
     16 
     17     @property
     18     def is_visible(self):
     19         return True
     20 
     21     def create_button_data(self, parent):
     22         return OmegaUpsellFixedButtonDataNode(parent)
     23 
     24 
     25 class OmegaUpsellFixedButtonDataNode(BtnDataNode):
     26 
     27     def __init__(self, parent):
     28         self._should_highlight = False
     29         self._should_highlight_thread = None
     30         BtnDataNode.__init__(self, parent=parent, btnType=neocomConst.BTNTYPE_UPSELL_FIXED, wndCls=OmegaUpsellWindow, label=GetByLabel('UI/CloneState/UpgradeToOmegaTitle'), btnID=btnIDs.OMEGA_UPSELL_FIXED, isRemovable=False, analyticID=UPSELL_FIXED_ANALYTIC_ID)
     31         omega_signals.on_omega_license_acquired.connect(self._update_should_highlight)
     32         omega_signals.on_omega_license_changed.connect(self._update_should_highlight)
     33         omega_signals.on_omega_license_expired.connect(self._update_should_highlight)
     34         omega_signals.on_omega_recurring_changed.connect(self._update_should_highlight)
     35         self._update_should_highlight()
     36 
     37     def __del__(self):
     38         if self._should_highlight_thread is not None:
     39             self._should_highlight_thread.kill()
     40             self._should_highlight_thread = None
     41         omega_signals.on_omega_license_acquired.disconnect(self._update_should_highlight)
     42         omega_signals.on_omega_license_changed.disconnect(self._update_should_highlight)
     43         omega_signals.on_omega_license_expired.disconnect(self._update_should_highlight)
     44         omega_signals.on_omega_recurring_changed.disconnect(self._update_should_highlight)
     45 
     46     def _update_should_highlight(self, *args):
     47         if self._should_highlight_thread is not None:
     48             self._should_highlight_thread.kill()
     49             self._should_highlight_thread = None
     50         self._should_highlight_thread = uthread2.StartTasklet(self._update_should_highlight_thread)
     51 
     52     def _update_should_highlight_thread(self):
     53         old_highlight = self._should_highlight
     54         try:
     55             self._should_highlight = get_clone_grade_svc().is_omega_about_to_lapse()
     56         except TimeoutException:
     57             self._should_highlight = False
     58 
     59         if old_highlight != self._should_highlight:
     60             self._UpdateHighlightState()
     61             self.OnBadgeCountChanged()
     62 
     63     def HasUnseenItems(self):
     64         return self._should_highlight