contentProviderEscalations.py (3204B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\agencyNew\contentProviders\contentProviderEscalations.py 2 from collections import defaultdict 3 from eve.client.script.ui.shared.agencyNew import agencyConst, agencyFilters 4 from eve.client.script.ui.shared.agencyNew.contentGroups import contentGroupConst 5 from eve.client.script.ui.shared.agencyNew.contentPieces.escalationContentPiece import EscalationContentPiece 6 from eve.client.script.ui.shared.agencyNew.contentPieces.escalationSystemContentPiece import EscalationSystemContentPiece 7 from eve.client.script.ui.shared.agencyNew.contentProviders.baseContentProvider import BaseContentProvider 8 import telemetry 9 from localization import GetByLabel 10 11 class ContentProviderEscalations(BaseContentProvider): 12 __notifyevents__ = BaseContentProvider.__notifyevents__ + ['OnEscalatingPathMessage', 'OnEscalationsDataUpdated'] 13 contentType = agencyConst.CONTENTTYPE_ESCALATION 14 contentGroup = contentGroupConst.contentGroupEscalations 15 contentTypeFilters = (agencyConst.CONTENTTYPE_SUGGESTED, agencyConst.CONTENTTYPE_COMBAT) 16 17 def __init__(self): 18 super(ContentProviderEscalations, self).__init__() 19 sm.RegisterNotify(self) 20 21 @telemetry.ZONE_METHOD 22 def _ConstructContentPieces(self): 23 contentPieces = [] 24 for solarSystemID, systemContentPieces in self.GetContentPiecesBySolarSystemID().iteritems(): 25 contentPiece = self.AppendEscalationSystemContentPiece(solarSystemID, systemContentPieces) 26 contentPieces.append(contentPiece) 27 28 contentPieces = sorted(contentPieces, key=self._GetSortKey) 29 self.ExtendContentPieces(contentPieces) 30 31 def _GetSortKey(self, contentPiece): 32 return contentPiece.GetJumpsToSelfFromCurrentLocation() 33 34 def AppendEscalationSystemContentPiece(self, solarSystemID, contentPieces): 35 contentPiece = EscalationSystemContentPiece(itemID=solarSystemID, solarSystemID=solarSystemID, contentPieces=contentPieces) 36 return contentPiece 37 38 def GetContentPiecesBySolarSystemID(self): 39 ret = defaultdict(list) 40 for contentPiece in self.GetEscalationContentPieces(): 41 ret[contentPiece.solarSystemID].append(contentPiece) 42 43 return ret 44 45 @telemetry.ZONE_METHOD 46 def GetEscalationContentPieces(self): 47 escalations = sm.GetService('journal').GetEscalations() 48 contentPieces = [ self.ConstructEscalationContentPiece(escalation) for escalation in escalations if escalation.destDungeon ] 49 return [ contentPiece for contentPiece in contentPieces if not contentPiece.IsExpired() ] 50 51 def ConstructEscalationContentPiece(self, escalationSite): 52 return EscalationContentPiece(solarSystemID=escalationSite.dungeon.solarSystemID, itemID=escalationSite.dungeon.instanceID, locationID=escalationSite.dungeon.solarSystemID, escalationSite=escalationSite, isNew=True) 53 54 def OnEscalatingPathMessage(self, instanceID): 55 if instanceID: 56 sm.GetService('neocom').Blink('agency', GetByLabel('UI/Neocom/Blink/NewEscalationMissionAvailable')) 57 58 def OnEscalationsDataUpdated(self): 59 self.InvalidateContentPieces()