maputils.py (15557B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\maps\maputils.py 2 import types 3 from carbon.common.script.sys.serviceConst import ROLE_GML 4 from collections import defaultdict 5 import evetypes 6 import trinity 7 import localization 8 import utillib 9 from carbonui.util.color import Color 10 from carbonui.util.various_unsorted import SortListOfTuples 11 from eve.client.script.ui.control.entries.util import GetFromClass 12 from eve.client.script.ui.shared.maps import mapcommon 13 from eve.client.script.ui.shared.planet.planetConst import PLANET_TYPES 14 from eve.common.lib import appConst as const 15 from eve.common.script.util.facwarCommon import GetOccupierFWFactions 16 from security.client.securityColor import get_security_status_color 17 18 def GetValidSolarsystemGroups(): 19 return [const.groupSun, 20 const.groupScannerProbe, 21 const.groupPlanet, 22 const.groupMoon, 23 const.groupStation, 24 const.groupAsteroidBelt, 25 const.groupBeacon, 26 const.groupCynosuralBeacon, 27 const.groupSatellite, 28 const.groupStargate, 29 const.groupSovereigntyClaimMarkers, 30 const.groupSovereigntyDisruptionStructures, 31 'bookmark', 32 'scanresult'] 33 34 35 def GetVisibleSolarsystemBrackets(): 36 return settings.user.ui.Get('groupsInSolarsystemMap', GetValidSolarsystemGroups()) 37 38 39 def GetHintsOnSolarsystemBrackets(): 40 return settings.user.ui.Get('hintsInSolarsystemMap', [const.groupStation]) 41 42 43 def GetMyPos(): 44 bp = sm.GetService('michelle').GetBallpark() 45 if bp and bp.ego: 46 ego = bp.balls[bp.ego] 47 myPos = trinity.TriVector(ego.x, ego.y, ego.z) 48 elif session.stationid: 49 s = sm.GetService('ui').GetStationStaticInfo(session.stationid) 50 myPos = trinity.TriVector(s.x, s.y, s.z) 51 else: 52 myPos = trinity.TriVector() 53 return myPos 54 55 56 def GetDistance(slimItem = None, mapData = None, ball = None, transform = None): 57 if ball: 58 return ball.surfaceDist 59 if slimItem: 60 ballPark = sm.GetService('michelle').GetBallpark() 61 if ballPark and slimItem.itemID in ballPark.balls: 62 return ballPark.balls[slimItem.itemID].surfaceDist 63 myPos = GetMyPos() 64 if mapData: 65 pos = trinity.TriVector(mapData.x, mapData.y, mapData.z) 66 elif transform: 67 pos = transform.translation 68 if type(pos) == types.TupleType: 69 pos = trinity.TriVector(*pos) 70 else: 71 return None 72 return (pos - myPos).Length() 73 74 75 def GetNameFromMapCache(messageID, messageType = None): 76 return localization.GetByMessageID(messageID) 77 78 79 def GetServicesOptions(): 80 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsClone'), mapcommon.STARMODE_SERVICE_Cloning], 81 [localization.GetByLabel('UI/Map/MapPallet/cbStarsFactory'), mapcommon.STARMODE_SERVICE_Factory], 82 [localization.GetByLabel('UI/Map/MapPallet/cbStarsFitting'), mapcommon.STARMODE_SERVICE_Fitting], 83 [localization.GetByLabel('UI/Map/MapPallet/cbStarsInsurance'), mapcommon.STARMODE_SERVICE_Insurance], 84 [localization.GetByLabel('UI/Map/MapPallet/cbStarsLaboratory'), mapcommon.STARMODE_SERVICE_Laboratory], 85 [localization.GetByLabel('UI/Map/MapPallet/cbStarsRepair'), mapcommon.STARMODE_SERVICE_RepairFacilities], 86 [localization.GetByLabel('UI/Map/MapPallet/cbStarsMilitia'), mapcommon.STARMODE_SERVICE_NavyOffices], 87 [localization.GetByLabel('UI/Map/MapPallet/cbStarsRefinery'), mapcommon.STARMODE_SERVICE_ReprocessingPlant], 88 [localization.GetByLabel('UI/Map/MapPallet/StarmodeSecurityOffices'), mapcommon.STARMODE_SERVICE_SecurityOffice]] 89 ret.sort() 90 return ret 91 92 93 def GetPersonalOptions(): 94 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsMyBookmarks'), mapcommon.STARMODE_BOOKMARKED], 95 [localization.GetByLabel('UI/Map/MapPallet/cbStarsMyAssets'), mapcommon.STARMODE_ASSETS], 96 [localization.GetByLabel('UI/Map/MapPallet/cbStarsIVisited'), mapcommon.STARMODE_VISITED], 97 [localization.GetByLabel('UI/Map/MapPallet/cbStarsCargoLeagal'), mapcommon.STARMODE_CARGOILLEGALITY], 98 [localization.GetByLabel('UI/Map/MapPallet/cbStarsPIScanRange'), mapcommon.STARMODE_PISCANRANGE]] 99 if (const.corpRoleAccountant | const.corpRoleJuniorAccountant) & session.corprole != 0: 100 ret += [[localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpOffices'), mapcommon.STARMODE_CORPOFFICES], 101 [localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpImpounded'), mapcommon.STARMODE_CORPIMPOUNDED], 102 [localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpProperty'), mapcommon.STARMODE_CORPPROPERTY], 103 [localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpDeliveries'), mapcommon.STARMODE_CORPDELIVERIES], 104 [localization.GetByLabel('UI/Corporations/Assets/AssetSafety'), mapcommon.STARMODE_CORPWRAPS]] 105 ret += [[localization.GetByLabel('UI/Map/MapPallet/cbStarsCorpMembers'), mapcommon.STARMODE_FRIENDS_CORP], 106 [localization.GetByLabel('UI/Map/MapPallet/cbStarsFleetMembers'), mapcommon.STARMODE_FRIENDS_FLEET], 107 [localization.GetByLabel('UI/Map/MapPallet/cbStarsMyAgents'), mapcommon.STARMODE_FRIENDS_AGENT], 108 [localization.GetByLabel('UI/Map/MapPallet/cbStarsMyJumpClones'), mapcommon.STARMODE_JUMP_CLONES]] 109 ret.append([localization.GetByLabel('UI/Map/MapPallet/cbStarsMyColonies'), mapcommon.STARMODE_MYCOLONIES]) 110 ret.sort() 111 return ret 112 113 114 def GetSovereignty_FactionalWarfareOptions(): 115 warfactionlist = [] 116 for factionID in GetOccupierFWFactions(): 117 factionName = cfg.eveowners.Get(factionID).name 118 warfactionlist.append([factionName.lower(), factionName, factionID]) 119 120 warfactionlist.sort() 121 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbModeMilitias'), (mapcommon.STARMODE_MILITIA, mapcommon.STARMODE_FILTER_FACWAR_ENEMY)]] 122 for fNL, factionName, factionID in warfactionlist: 123 ret.append([factionName, (mapcommon.STARMODE_MILITIA, factionID)]) 124 125 ret.append([localization.GetByLabel('UI/Map/MapPallet/cbStarsMilitiaDestroyed1H'), mapcommon.STARMODE_MILITIAKILLS1HR]) 126 ret.append([localization.GetByLabel('UI/Map/MapPallet/cbStarsMilitiaDestroyed24H'), mapcommon.STARMODE_MILITIAKILLS24HR]) 127 return ret 128 129 130 def GetSovereignty_InsurgencyOptions(): 131 ret = [] 132 ret.append([localization.GetByLabel('UI/PirateInsurgencies/dashboardCaption'), mapcommon.STARMODE_INSURGENCY]) 133 ret.append([localization.GetByLabel('UI/PirateInsurgencies/corruption'), mapcommon.STARMODE_INSURGENCY_CORRUPTION]) 134 ret.append([localization.GetByLabel('UI/PirateInsurgencies/suppression'), mapcommon.STARMODE_INSURGENCY_SUPPRESSION]) 135 return ret 136 137 138 def GetSovereignty_SovereigntyOptions(): 139 factionlist = [] 140 factionIDs = sm.GetService('starmap').GetAllFactionsAndAlliances() 141 cfg.eveowners.Prime(factionIDs) 142 for factionID in factionIDs: 143 factionName = cfg.eveowners.Get(factionID).name 144 factionlist.append([factionName.lower(), factionName, factionID]) 145 146 factionlist.sort() 147 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbModeFactions'), (mapcommon.STARMODE_FACTION, mapcommon.STARMODE_FILTER_FACWAR_ENEMY)], [localization.GetByLabel('UI/Map/MapPallet/cbStarsByStandings'), mapcommon.STARMODE_SOV_STANDINGS], [localization.GetByLabel('UI/Map/MapPallet/cbStarsByEmpireFactions'), (mapcommon.STARMODE_FACTIONEMPIRE, mapcommon.STARMODE_FILTER_EMPIRE)]] 148 for fNL, factionName, factionID in factionlist: 149 ret.append([factionName, (mapcommon.STARMODE_FACTION, factionID)]) 150 151 return ret 152 153 154 def GetSovereignty_ChangesOptions(): 155 ret = [(localization.GetByLabel('UI/Map/MapPallet/cbStarsByRecientSovChanges'), mapcommon.STARMODE_SOV_CHANGE), (localization.GetByLabel('UI/Map/MapPallet/cbStarsBySovGain'), mapcommon.STARMODE_SOV_GAIN), (localization.GetByLabel('UI/Map/MapPallet/cbStarsBySovLoss'), mapcommon.STARMODE_SOV_LOSS)] 156 return ret 157 158 159 def GetAutopilotOptions(): 160 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsAdvoidance'), mapcommon.STARMODE_AVOIDANCE]] 161 return ret 162 163 164 def GetStatisticsOptions(): 165 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsPilots30Min'), mapcommon.STARMODE_PLAYERCOUNT], 166 [localization.GetByLabel('UI/Map/MapPallet/cbStarsPilotsDocked'), mapcommon.STARMODE_PLAYERDOCKED], 167 [localization.GetByLabel('UI/Map/MapPallet/cbStarsJumps'), mapcommon.STARMODE_JUMPS1HR], 168 [localization.GetByLabel('UI/Map/MapPallet/cbStarsDestroyed'), mapcommon.STARMODE_SHIPKILLS1HR], 169 [localization.GetByLabel('UI/Map/MapPallet/cbStarsDestroyed24H'), mapcommon.STARMODE_SHIPKILLS24HR], 170 [localization.GetByLabel('UI/Map/MapPallet/cbStarsPoded1H'), mapcommon.STARMODE_PODKILLS1HR], 171 [localization.GetByLabel('UI/Map/MapPallet/cbStarsPoded24H'), mapcommon.STARMODE_PODKILLS24HR], 172 [localization.GetByLabel('UI/Map/MapPallet/cbStarsNPCDestroyed'), mapcommon.STARMODE_FACTIONKILLS1HR], 173 [localization.GetByLabel('UI/Map/MapPallet/cbStarsStationCount'), mapcommon.STARMODE_STATIONCOUNT], 174 [localization.GetByLabel('UI/Map/MapPallet/cbStarsCynosuarl'), mapcommon.STARMODE_CYNOSURALFIELDS], 175 [localization.GetByLabel('UI/Map/MapPallet/SolarSystemInterference'), mapcommon.STARMODE_SYSTEM_INTERFERENCE]] 176 ret.sort() 177 return ret 178 179 180 def GetSovereignty_Development_IndicesOptions(): 181 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsByDevIdxStrategic'), mapcommon.STARMODE_INDEX_STRATEGIC], [localization.GetByLabel('UI/Map/MapPallet/cbStarsByDevIdxMilitary'), mapcommon.STARMODE_INDEX_MILITARY], [localization.GetByLabel('UI/Map/MapPallet/cbStarsByDevIdxIndustry'), mapcommon.STARMODE_INDEX_INDUSTRY]] 182 return ret 183 184 185 def GetPlanetsOptions(): 186 ret = [] 187 for planetTypeID in PLANET_TYPES: 188 ret.append((evetypes.GetName(planetTypeID), (mapcommon.STARMODE_PLANETTYPE, planetTypeID))) 189 190 ret.sort() 191 return ret 192 193 194 def GetIndustry_JobsOptions(): 195 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsByJobsStartedLast24Hours'), mapcommon.STARMODE_JOBS24HOUR], 196 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByManufacturingJobsStartedLast24Hours'), mapcommon.STARMODE_MANUFACTURING_JOBS24HOUR], 197 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByResearchTimeJobsStartedLast24Hours'), mapcommon.STARMODE_RESEARCHTIME_JOBS24HOUR], 198 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByResearchMaterialJobsStartedLast24Hours'), mapcommon.STARMODE_RESEARCHMATERIAL_JOBS24HOUR], 199 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByCopyJobsStartedLast24Hours'), mapcommon.STARMODE_COPY_JOBS24HOUR], 200 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByInventionJobsStartedLast24Hours'), mapcommon.STARMODE_INVENTION_JOBS24HOUR]] 201 return ret 202 203 204 def GetIndustry_CostModifierOptions(): 205 return [[localization.GetByLabel('UI/Map/MapPallet/cbStarsByManufacturingIndustryCostModifier'), mapcommon.STARMODE_INDUSTRY_MANUFACTURING_COST_INDEX], 206 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByResearchTimeIndustryCostModifier'), mapcommon.STARMODE_INDUSTRY_RESEARCHTIME_COST_INDEX], 207 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByResearchMaterialIndustryCostModifier'), mapcommon.STARMODE_INDUSTRY_RESEARCHMATERIAL_COST_INDEX], 208 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByCopyIndustryCostModifier'), mapcommon.STARMODE_INDUSTRY_COPY_COST_INDEX], 209 [localization.GetByLabel('UI/Map/MapPallet/cbStarsByInventionIndustryCostModifier'), mapcommon.STARMODE_INDUSTRY_INVENTION_COST_INDEX]] 210 211 212 def GetActiveStarColorModeLabel(): 213 activeMode = settings.user.ui.Get('starscolorby', mapcommon.STARMODE_SECURITY) 214 groupFunctions = [GetRootOptions, 215 GetAutopilotOptions, 216 GetPersonalOptions, 217 GetPlanetsOptions, 218 GetServicesOptions, 219 GetSovereignty_Development_IndicesOptions, 220 GetSovereignty_FactionalWarfareOptions, 221 GetSovereignty_InsurgencyOptions, 222 GetSovereignty_ChangesOptions, 223 GetStatisticsOptions, 224 GetSovereignty_SovereigntyOptions, 225 GetIndustry_JobsOptions, 226 GetIndustry_CostModifierOptions] 227 for function in groupFunctions: 228 for label, starModeConst in function(): 229 if starModeConst == activeMode: 230 return label 231 232 233 def GetRootOptions(): 234 ret = [[localization.GetByLabel('UI/Map/MapPallet/cbStarsActual'), mapcommon.STARMODE_REAL], 235 [localization.GetByLabel('UI/Map/MapPallet/cbStarsSecurity'), mapcommon.STARMODE_SECURITY], 236 [localization.GetByLabel('UI/Map/MapPallet/cbStarsRegion'), mapcommon.STARMODE_REGION], 237 [localization.GetByLabel('UI/Map/MapPallet/cbStarsDedDeadspace'), mapcommon.STARMODE_DUNGEONS], 238 [localization.GetByLabel('UI/Map/MapPallet/cbStarsDedAgents'), mapcommon.STARMODE_DUNGEONSAGENTS], 239 [localization.GetByLabel('UI/Map/MapPallet/cbStarsIncursion'), mapcommon.STARMODE_INCURSION], 240 [localization.GetByLabel('UI/Map/MapPallet/cbStarsRoamingWeather'), mapcommon.STARMODE_ROAMING_WEATHER]] 241 if session.role & ROLE_GML: 242 ret.append([localization.GetByLabel('UI/Map/MapPallet/cbStarsIncursionGM'), mapcommon.STARMODE_INCURSIONGM]) 243 ret.sort() 244 return ret 245 246 247 def GetSolarSystemOptions(): 248 from eve.client.script.ui.shared.maps.entries import BracketSelectorEntry 249 validGroups = GetValidSolarsystemGroups() 250 wantedGroups = GetVisibleSolarsystemBrackets() 251 wantedHints = GetHintsOnSolarsystemBrackets() 252 scrolllist = [] 253 for groupID in validGroups: 254 data = utillib.KeyVal() 255 data.visible = groupID in wantedGroups 256 data.showhint = groupID in wantedHints 257 data.groupID = groupID 258 if type(groupID) in types.StringTypes: 259 cerbString = {'bookmark': 'UI/Map/MapPallet/cbSolarSystem_bookmark', 260 'scanresult': 'UI/Map/MapPallet/cbSolarSystem_scanresult'}[groupID] 261 data.label = localization.GetByLabel(cerbString) 262 else: 263 data.label = evetypes.GetGroupNameByGroup(groupID) 264 scrolllist.append((data.label, GetFromClass(BracketSelectorEntry, data))) 265 266 if scrolllist: 267 scrolllist = SortListOfTuples(scrolllist) 268 return scrolllist 269 270 271 def GetRoundedSecurityStatus(security): 272 sec = round(security, 1) 273 if sec == -0.0: 274 sec = 0.0 275 return sec 276 277 278 def GetColorBySecurityStatus(sec): 279 return get_security_status_color(sec) 280 281 282 def GetSecurityStatusText(security): 283 security = GetRoundedSecurityStatus(security) 284 color = GetColorBySecurityStatus(security) 285 return '<color=%s>%s</color>' % (Color.RGBtoHex(*color), security) 286 287 288 def GetJumpClonesBySystemID(): 289 from eve.client.script.ui.shared.neocom.charsheet.jumpClonesPanel import JumpClone 290 bySystemID = defaultdict(list) 291 stuffToPrime = set() 292 allClonesInDockableLocations = [] 293 for eachCloneInfo in sm.GetService('clonejump').GetClones(): 294 clone = JumpClone(clone_id=eachCloneInfo.jumpCloneID, location_id=eachCloneInfo.locationID, name=eachCloneInfo.cloneName, implants=[]) 295 if clone.in_station or clone.in_structure: 296 allClonesInDockableLocations.append(clone) 297 298 if stuffToPrime: 299 cfg.evelocations.Prime(stuffToPrime) 300 for eachClone in allClonesInDockableLocations: 301 solarSystemID = None 302 if eachClone.in_station: 303 solarSystemID = cfg.stations.Get(eachClone.location_id).solarSystemID 304 else: 305 structure = sm.GetService('structureDirectory').GetStructureInfo(eachClone.location_id) 306 if structure is not None: 307 solarSystemID = structure.solarSystemID 308 if solarSystemID: 309 bySystemID[solarSystemID].append(eachClone) 310 311 return bySystemID