bannerEvent.py (2474B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\activities\bannerEvent.py 2 import webbrowser 3 import eveexceptions 4 from carbonui import uiconst 5 from carbonui.uicore import uicore 6 from eve.client.script.ui.shared.activities.activitiesUIConst import CHOICE_TOGGLE_AURUM_STORE_BY_CATEGORY_ID, CHOICE_TOGGLE_AURUM_STORE_BY_TYPE_IDS, CHOICE_OPEN_SEASON, CHOICE_URL 7 from localization import GetByLabel 8 from eve.client.script.ui.shared.message_bus.newsCarouselMessenger import NewsCarouselMessenger 9 from player_messaging.client.ui_message import prompt_player_fsd_dialog 10 11 def _OpenSeason(_): 12 uicore.cmd.OpenSeason() 13 return True 14 15 16 def _ToggleAurumStoreByCategoryID(activity): 17 categoryID = activity.GetIntegerParameter() 18 sm.GetService('vgsService').ToggleStore(categoryID) 19 return True 20 21 22 def _GetAvailableTypeIds(typeIds): 23 productTypeIds = set([ product.typeId for offer in sm.GetService('vgsService').GetStore().GetOffers().itervalues() if offer.canPurchase for product in offer.productQuantities.itervalues() ]) 24 return list(productTypeIds.intersection(typeIds)) 25 26 27 def _ToggleAurumStoreByTypeIds(activity): 28 typeIds = _GetAvailableTypeIds(set(activity.GetIntegerListParameter())) 29 sm.GetService('vgsService').OpenStore(typeIds=typeIds) 30 return True 31 32 33 def _OpenURL(activity): 34 url = activity.GetUrl() 35 if not url: 36 return False 37 header = GetByLabel('UI/NewActivitiesNotify/GoToWebsiteHeader') 38 question = GetByLabel('UI/NewActivitiesNotify/GoToWebsiteQuestion') 39 redirectStatus = False 40 if url and prompt_player_fsd_dialog('CustomQuestion', {'header': header, 41 'question': question}, uiconst.OKCANCEL) == uiconst.ID_OK: 42 webbrowser.open_new(url) 43 redirectStatus = True 44 return redirectStatus 45 46 47 OPEN_DICT = {CHOICE_TOGGLE_AURUM_STORE_BY_CATEGORY_ID: _ToggleAurumStoreByCategoryID, 48 CHOICE_TOGGLE_AURUM_STORE_BY_TYPE_IDS: _ToggleAurumStoreByTypeIds, 49 CHOICE_OPEN_SEASON: _OpenSeason, 50 CHOICE_URL: _OpenURL} 51 52 @eveexceptions.EatsExceptions('protoClientLogs') 53 def _LogAcknowledged(ad_id): 54 message_bus = NewsCarouselMessenger(sm.GetService('publicGatewaySvc')) 55 message_bus.acknowledged(ad_id) 56 57 58 def DoAction(activity): 59 event = activity.GetEvent() 60 if event is None: 61 return False 62 method = OPEN_DICT.get(event) 63 if callable(method): 64 _LogAcknowledged(activity.GetID()) 65 return method(activity) 66 return False