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

omegaOfferWindow.py (4179B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\contextualOffers\client\UI\omegaOffer\omegaOfferWindow.py
      2 from carbonui import uiconst
      3 from contextualOffers.client.UI.bracketBorderWindow import BracketBorderWindow
      4 from contextualOffers.client.UI.omegaOffer.omegaPurchaseContainer import OmegaPurchaseContainer
      5 from contextualOffers.client.UI.omegaOffer.omegaConfirmationContainer import OmegaConfirmationContainer
      6 from localization import GetByLabel
      7 from evephotosvc.const import NONE_PATH
      8 import logging
      9 log = logging.getLogger(__name__)
     10 DEFAULT_IMAGE = 'res:/UI/Texture/Vgs/missing_image.png'
     11 
     12 class OmegaOfferWindow(BracketBorderWindow):
     13     default_name = 'omegaOfferWindow'
     14 
     15     def ApplyAttributes(self, attributes):
     16         BracketBorderWindow.ApplyAttributes(self, attributes)
     17         self.activeOfferID = -1
     18 
     19     def ConstructContent(self):
     20         self.purchaseCont = OmegaPurchaseContainer(name='purchaseCont', parent=self.innerCont, align=uiconst.CENTER, height=self.frameCont.height, width=self.frameCont.width, onButtonClick=self.OnPurchaseButtonClicked, idx=0)
     21         self.confirmationCont = OmegaConfirmationContainer(name='purchaseCont', parent=self.innerCont, align=uiconst.CENTER, height=self.frameCont.height, width=self.frameCont.width, onButtonClick=self.CloseButtonClicked, idx=0)
     22 
     23     def _load_texture_from_url(self, url):
     24         if not url:
     25             raise AttributeError('UrlSprite requires image URL as a parameter')
     26         photo_service = sm.GetService('photo')
     27         texture, width, height = photo_service.GetTextureFromURL(url, retry=False)
     28         if texture is None or texture.resPath == NONE_PATH:
     29             texture, width, height = photo_service.GetTextureFromURL(DEFAULT_IMAGE, retry=False)
     30         self.bannerSprite.texture = texture
     31         self.bannerSprite.width = width
     32         self.bannerSprite.height = height
     33 
     34     def _set_background(self, uri):
     35         if uri:
     36             if uri.startswith('res:'):
     37                 self.SetBackgroundImage(uri)
     38             elif uri.startswith('https:'):
     39                 self._load_texture_from_url(uri)
     40             elif uri.startswith('http:'):
     41                 from eveprefs import prefs
     42                 if prefs.clusterMode == 'LOCAL':
     43                     self._load_texture_from_url(uri)
     44                 else:
     45                     raise AttributeError(u'Insecure background URLs are only allowed when testing locally')
     46             else:
     47                 raise AttributeError(u'Unknown background uri schema in %r' % uri)
     48 
     49     def OnPurchaseButtonClicked(self):
     50         try:
     51             sm.GetService('contextualOfferSvc').OnBuyClicked(self.activeOfferID)
     52         except Exception:
     53             raise UserError('FailedToOpenOfferUrl')
     54 
     55     def OpenPurchaseView(self, message):
     56         self._set_background(message.get('purchaseBackground', None))
     57         self.activeOfferID = message.get('offerID', -1)
     58         self.purchaseCont.LoadOffer(offerID=self.activeOfferID, title=message.get('purchaseTitle', ''), description=message.get('purchaseDescription', ''), offerPrice=message.get('offerPrice', ''), originalPrice=message.get('originalPrice', ''), discount=message.get('discount', ''), buttonText=message.get('purchaseButtonLabel', ''), remainingText=GetByLabel('UI/Common/Remaining'), tooltipHeader=message.get('tooltipHeader', ''), tooltipDescription=message.get('tooltipDescription', ''))
     59         self.purchaseCont.SetState(uiconst.UI_NORMAL)
     60         self.confirmationCont.SetState(uiconst.UI_HIDDEN)
     61 
     62     def OpenConfirmationView(self, message):
     63         self.SetBackgroundImage(message.get('confirmationBackground', None))
     64         self.confirmationCont.SetTitleText(message.get('confirmationTitle', ''))
     65         self.confirmationCont.SetDescriptionText(message.get('confirmationDescription', ''))
     66         self.confirmationCont.SetButtonText(message.get('confirmationButtonLabel', ''))
     67         self.purchaseCont.SetState(uiconst.UI_HIDDEN)
     68         self.confirmationCont.SetState(uiconst.UI_NORMAL)
     69 
     70     def PostAnimEnter(self):
     71         self.purchaseCont.AnimateIn()
     72 
     73     def OnTimerUpdated(self, value):
     74         self.purchaseCont.OnTimerUpdated(value)