map.py (9639B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\pirateinsurgency\client\dashboard\map.py 2 from __future__ import print_function 3 from eve.client.script.ui.services.insurgenceDashboardSvc import WrapCallbackWithErrorHandling 4 from functools import partial 5 import evecamera 6 from carbonui import uiconst 7 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel 8 from eve.client.script.ui.shared.mapView import mapViewConst 9 from eve.client.script.ui.shared.mapView.mapView import MapView 10 from eve.client.script.ui.shared.mapView.mapViewConst import MARKERID_CSBLOB, STAR_SIZE_STANDARD 11 from eve.client.script.ui.shared.mapView.mapViewData import mapViewData 12 from eve.common.script.util.facwarCommon import GetInsurgencyEnemyFactions, IsPirateFWFaction, IsOccupierFWFaction 13 from pirateinsurgency.client.dashboard.const import WARZONE_ID_TO_PIRATE_FACTION_ID 14 from pirateinsurgency.client.dashboard.mapMarker import InsurgencyBlobMarker 15 16 class MapPanel(MapView): 17 cameraID = evecamera.CAM_INSURGENCY_MAP 18 default_allowedSystems = [30002799, 19 30002794, 20 30002795, 21 30002796] 22 23 def ApplyAttributes(self, attributes): 24 self.loadedSystems = False 25 self.insurgencySystems = attributes.get('insurgencySystems', MapPanel.default_allowedSystems) 26 self.dashboardSvc = attributes.get('dashboardSvc') 27 self.campaignIDs = attributes.get('campaignIDs') 28 self.systemIDToCampaignID = {} 29 allowedSystemsSet = set(self.insurgencySystems) 30 mapCacheData = mapViewData.GetStarMapCache() 31 for snapshot in self.dashboardSvc.GetCurrentCampaignSnapshots(): 32 neighbouringSystemIDs = [] 33 for systemID in snapshot.coveredSolarsystemIDs: 34 self.systemIDToCampaignID[systemID] = snapshot.campaignID 35 neighbours = mapCacheData['solarSystems'][systemID]['neighbours'] 36 neighbouringSystemIDs.extend(neighbours) 37 38 allowedSystemsSet.update(neighbouringSystemIDs) 39 for systemID in neighbouringSystemIDs: 40 self.systemIDToCampaignID[systemID] = snapshot.campaignID 41 42 self.allowedSystems = list(allowedSystemsSet) 43 self.initialInterestID = None 44 focusSystem = self.GetBestFocusSystem() 45 if focusSystem: 46 self.initialInterestID = focusSystem 47 else: 48 self.initialInterestID = self.allowedSystems[0] 49 super(MapPanel, self).ApplyAttributes(attributes) 50 self.systems = {} 51 52 def _ConstructScene(self, _interestID, zoomToItem): 53 self.sceneContainer.Hide() 54 loadingWheel = LoadingWheel(parent=self, align=uiconst.CENTER) 55 self.sceneContainer.Startup() 56 self.camera.SetUpdateCallback(self.OnCameraUpdate) 57 self.ConstructStarDataTexture() 58 self.ConstructMapScene() 59 self.ConstructMapRoot() 60 self.ConstructMarkersHandler() 61 self.ConstructBookmarkHandler() 62 self.CreateStarParticles() 63 self.CreateJumpLineSet() 64 self.LoadJumpLines() 65 self.UpdateMapLayout() 66 self.ReconstructMyLocationMarker() 67 self.ShowMyHomeStation() 68 self._SetActiveItemID(self.initialInterestID) 69 self.CheckLoadAllMarkers() 70 self.InitCameraFocus(zoomToItem) 71 self.constructSceneThread = None 72 loadingWheel.Hide() 73 self.sceneContainer.Show() 74 self.ApplyStarColors() 75 for campaignID in self.campaignIDs: 76 fun = partial(self.ShowBlobs, snapshot=self.dashboardSvc.GetCurrentCampaignSnapshotByID(campaignID)) 77 wrappedCallback = WrapCallbackWithErrorHandling(fun, parentContainer=None) 78 self.dashboardSvc.RequestAllCorruptionAndSuppressionValuesForCampaignID(campaignID, wrappedCallback) 79 80 def GetStarSize(self, solarSystemID): 81 return STAR_SIZE_STANDARD 82 83 def PrintResult(self, data): 84 print(data) 85 86 def ShowBlobs(self, data, snapshot = None): 87 if self.destroyed: 88 return 89 corruptionData = data['corruption'] 90 suppressionData = data['suppression'] 91 for solarSystemID, data in corruptionData.iteritems(): 92 corruptionStage = data.stage 93 mapNode = self.layoutHandler.GetNodeBySolarSystemID(solarSystemID) 94 solarSystemPosition = mapNode.position 95 localPosition = self.SolarSystemPosToMapPos(solarSystemPosition) 96 markerID = (MARKERID_CSBLOB, solarSystemID) 97 suppressionStage = suppressionData[solarSystemID].stage 98 iceHeist = None 99 iceHeistDungeons = self.dashboardSvc.GetIceHeistInstances_Memoized() 100 if solarSystemID in iceHeistDungeons and iceHeistDungeons[solarSystemID]: 101 iceHeist = iceHeistDungeons[solarSystemID] 102 self.markersHandler.AddSolarSystemBasedMarker(markerID, InsurgencyBlobMarker, snapshot=snapshot, solarSystemID=solarSystemID, mapPositionLocal=localPosition, mapPositionSolarSystem=solarSystemPosition, texturePath='res:/UI/Texture/classes/pirateinsurgencies/map/CorruptionCircle05.png', corruptionStage=corruptionStage, suppressionStage=suppressionStage, dashboardSvc=self.dashboardSvc, iceHeist=iceHeist) 103 self.markersAlwaysVisible.add(markerID) 104 105 def LoadJumpLines(self): 106 self.allianceJumpLines = [] 107 self.jumpLineInfoByLineID = {} 108 self.allJumpBridges = [] 109 self.myJumpBridges = [] 110 lineSet = self.solarSystemJumpLineSet 111 defaultColor = (0, 0, 0, 0) 112 defaultPos = (0, 0, 0) 113 for lineData in mapViewData.IterateJumps(): 114 lineID = lineSet.AddStraightLine(defaultPos, defaultColor, defaultPos, defaultColor, mapViewConst.JUMPLINE_BASE_WIDTH) 115 lineData.lineID = lineID 116 fromNode = self.layoutHandler.GetNodeBySolarSystemID(lineData.fromSolarSystemID) 117 toNode = self.layoutHandler.GetNodeBySolarSystemID(lineData.toSolarSystemID) 118 if fromNode is not None and toNode is not None and lineData.fromSolarSystemID in self.allowedSystems and lineData.toSolarSystemID in self.allowedSystems: 119 fromNode.AddLineData(lineData) 120 toNode.AddLineData(lineData) 121 self.jumpLineInfoByLineID[lineID] = lineData 122 123 def SetSelectedMarker(self, markerObject, **kwds): 124 super(MapPanel, self).SetSelectedMarker(markerObject, **kwds) 125 if markerObject.solarSystemID is not None: 126 self.dashboardSvc.OnSolarSystemSelectedFromMap(markerObject.solarSystemID) 127 128 def ReconstructMyLocationMarker(self): 129 pass 130 131 def ShowMyHomeStation(self): 132 pass 133 134 def _GetKnownUniverseSolarSystems(self): 135 if self.loadedSystems: 136 return self.systems 137 for systemID, system in mapViewData.GetKnownUniverseSolarSystems().iteritems(): 138 if systemID in self.allowedSystems: 139 self.systems[systemID] = system 140 141 return self.systems 142 143 def _GetKnownUniverseConstellations(self): 144 constellations = set() 145 for systemID, system in self._GetKnownUniverseSolarSystems().iteritems(): 146 constellations.add(system.constellationID) 147 148 constellationData = {} 149 for constellationID in constellations: 150 constellationData[constellationID] = mapViewData.GetKnownUniverseConstellations()[constellationID] 151 152 return constellationData 153 154 def _GetKnownUniverseRegions(self): 155 regions = set() 156 for systemID, system in self._GetKnownUniverseSolarSystems().iteritems(): 157 regions.add(system.regionID) 158 159 regionData = {} 160 for regionID in regions: 161 regionData[regionID] = mapViewData.GetKnownUniverseRegions()[regionID] 162 163 return regionData 164 165 def GetBestFocusSystem(self): 166 campaignSnapshots = self.dashboardSvc.GetCurrentCampaignSnapshots() 167 if len(campaignSnapshots) == 0: 168 return 169 if session.solarsystemid2 in self.allowedSystems: 170 return session.solarsystemid2 171 if session.warfactionid is not None: 172 if IsOccupierFWFaction(session.warfactionid): 173 enemyPirateFactions = GetInsurgencyEnemyFactions(session.warfactionid) 174 FOBSystem = None 175 for id in enemyPirateFactions: 176 FOBSystem = self.GetPirateFactionFOBSystem(id, campaignSnapshots) 177 if FOBSystem is not None: 178 break 179 180 if FOBSystem is not None: 181 return FOBSystem 182 elif IsPirateFWFaction(session.warfactionid): 183 FOBSystemID = self.GetPirateFactionFOBSystem(session.warfactionid, campaignSnapshots) 184 if FOBSystemID is not None: 185 return FOBSystemID 186 return campaignSnapshots[0].originSolarsystemID 187 188 def GetPirateFactionFOBSystem(self, pirateFactionID, campaignSnapshots): 189 FOBSystemID = None 190 for snapshot in campaignSnapshots: 191 if WARZONE_ID_TO_PIRATE_FACTION_ID[snapshot.warzoneID] == pirateFactionID: 192 FOBSystemID = snapshot.originSolarsystemID 193 194 return FOBSystemID 195 196 def OnSessionChanged(self, isRemote, session, change): 197 if 'solarsystemid' in change: 198 lastSystem, newSystem = change['solarsystemid'] 199 if self.activeItemID == lastSystem and newSystem in self.allowedSystems: 200 self.dashboardSvc.OnSolarSystemSelectedFromMap(newSystem) 201 self.SetActiveItemID(newSystem, zoomToItem=True) 202 203 def LoadVulnerableSkyhooks(self): 204 pass 205 206 def LoadLandmarkMarkers(self): 207 pass