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

starModeHandler.py (62701B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\maps\starModeHandler.py
      2 import math
      3 import string
      4 from characterdata.factions import get_faction_name
      5 from collections import defaultdict
      6 import evetypes
      7 import geo2
      8 import inventorycommon.typeHelpers
      9 import talecommon.const as taleConst
     10 import trinity
     11 from eve.client.script.ui import eveColor
     12 from eve.client.script.ui.shared.maps import mapcommon
     13 from eve.client.script.ui.shared.maps.mapcommon import LegendItem, COLOR_STANDINGS_GOOD, COLOR_STANDINGS_BAD, COLOR_STANDINGS_NEUTRAL
     14 from eve.client.script.ui.shared.maps.maputils import GetJumpClonesBySystemID
     15 from eve.client.script.ui.util import uix
     16 from eve.common.lib import appConst
     17 from eve.common.script.sys import eveCfg, idCheckers
     18 from evestations.data import service_in_station_operation
     19 from factionwarfare.client.text import GetVictoryPointStateText
     20 from eve.common.script.util.facwarCommon import GetOccupierFWFactions, IsAnyFWFaction
     21 from localization import GetByLabel, GetByMessageID
     22 from npcs.divisions import get_division_name
     23 from npcs.npccorporations import get_corporation_faction_id
     24 from security.client.securityColor import COLORCURVE_SECURITY
     25 from solarsysteminterference.client.ui import GetInterferenceBandLabel
     26 from solarsysteminterference.const import INTERFERENCE_BAND_LOW, INTERFERENCE_BAND_MEDIUM, INTERFERENCE_BAND_HIGH, INTERFERENCE_BAND_NONE
     27 from carbonui.util.color import Color
     28 DEFAULT_MAX_COLOR = trinity.TriColor(0.0, 1.0, 0.0)
     29 COLOR_GREEN = trinity.TriColor(0.0, 1.0, 0.0)
     30 COLOR_YELLOW = trinity.TriColor(1.0, 1.0, 0.0)
     31 COLOR_ORANGE = trinity.TriColor(1.0, 0.4, 0.0)
     32 COLOR_RED = trinity.TriColor(1.0, 0.0, 0.0)
     33 COLOR_WHITE = trinity.TriColor(1.0, 1.0, 1.0)
     34 COLOR_GRAY = trinity.TriColor(0.5, 0.5, 0.5)
     35 COLOR_PURPLE = trinity.TriColor(0.5, 0.25, 0.75)
     36 
     37 def ColorStarsByDevIndex(colorInfo, starColorMode, indexID, indexName):
     38     sovSvc = sm.GetService('sov')
     39     indexData = sovSvc.GetAllDevelopmentIndicesMapped()
     40     color = trinity.TriColor(0.4, 0.4, 1.0)
     41     hintFunc = lambda indexName, level: GetByLabel('UI/Map/StarModeHandler/devIndxLevel', indexName=indexName, level=level)
     42     for solarSystemID, info in indexData.iteritems():
     43         levelInfo = sovSvc.GetIndexLevel(info[indexID], indexID)
     44         if levelInfo.level == 0:
     45             continue
     46         size = levelInfo.level * 2.0
     47         colorInfo.solarSystemDict[solarSystemID] = (size,
     48          1.0,
     49          (hintFunc, (indexName, levelInfo.level)),
     50          color)
     51 
     52     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/devIndxUndevloped'), mapcommon.NEUTRAL_COLOR, data=None))
     53     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/devIndxDevloped'), color, data=None))
     54 
     55 
     56 def HintMyAssets(stationData):
     57     c = []
     58     for stationID, itemCount in stationData:
     59         shortStationName = uix.EditStationName(cfg.evelocations.Get(stationID).name, usename=1)
     60         subc = GetByLabel('UI/Map/StarModeHandler/StationNameWithItemCount', shortStationName=shortStationName, numItems=itemCount)
     61         c.append((subc, ('OnClick', 'OpenAssets', (stationID,))))
     62 
     63     return ([GetByLabel('UI/Map/StarModeHandler/assetsMyAssets')], c)
     64 
     65 
     66 def ColorStarsByAssets(colorInfo, starColorMode):
     67     myassets = sm.GetService('assets').GetAll('allitems')
     68     assetColor = trinity.TriColor(0.5, 0.1, 0.0)
     69     bySystemID = {}
     70     stuffToPrime = []
     71     for solarsystemID, station in myassets:
     72         stuffToPrime.append(station.stationID)
     73         stuffToPrime.append(solarsystemID)
     74         if solarsystemID not in bySystemID:
     75             bySystemID[solarsystemID] = []
     76         bySystemID[solarsystemID].append(station)
     77 
     78     if stuffToPrime:
     79         cfg.evelocations.Prime(stuffToPrime)
     80 
     81     def hintFunc(stationData):
     82         hint = ''
     83         for stationID, itemCount in stationData:
     84             shortStationName = uix.EditStationName(cfg.evelocations.Get(stationID).name, usename=1)
     85             subc = GetByLabel('UI/Map/StarModeHandler/StationNameWithItemCount', shortStationName=shortStationName, numItems=itemCount)
     86             if hint:
     87                 hint += '<br>'
     88             hint += '- <url=localsvc:method=ShowAssets&stationID=%d>%s</url>' % (stationID, subc)
     89 
     90         return hint
     91 
     92     for solarsystemID, stations in bySystemID.iteritems():
     93         itemCount = sum((station.itemCount for station in stations))
     94         size = 4.0 + math.log10(itemCount)
     95         stationData = [ (station.stationID, station.itemCount) for station in stations ]
     96         colorInfo.solarSystemDict[solarsystemID] = (size,
     97          1.0,
     98          (hintFunc, (stationData,)),
     99          assetColor)
    100 
    101     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/assetsNoAssets'), mapcommon.NEUTRAL_COLOR, data=None))
    102     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/assetsHasAssets'), assetColor, data=None))
    103 
    104 
    105 def ColorStarsByVisited(colorInfo, starColorMode):
    106     history = sm.RemoteSvc('map').GetSolarSystemVisits()
    107     visited = []
    108     for entry in history:
    109         visited.append((entry.lastDateTime, entry.solarSystemID, entry.visits))
    110 
    111     if len(visited):
    112         divisor = 1.0 / float(len(visited))
    113     visited.sort()
    114     starmap = sm.GetService('starmap')
    115     hintFunc = lambda solarSystemID, visits, lastDateTime: GetByLabel('UI/Map/StarModeHandler/visitedLastVisist', system=solarSystemID, count=visits, lastVisit=lastDateTime)
    116     for i, (lastDateTime, solarSystemID, visits) in enumerate(visited):
    117         colorInfo.solarSystemDict[solarSystemID] = (3.0 + math.log10(float(visits)) * 4.0,
    118          float(i) * divisor,
    119          (hintFunc, (solarSystemID, visits, lastDateTime)),
    120          None)
    121 
    122     colorInfo.colorList = (trinity.TriColor(0.3, 0.0, 0.0), trinity.TriColor(1.0, 0.0, 0.0), trinity.TriColor(1.0, 1.0, 0.0))
    123     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/visitedNever'), mapcommon.NEUTRAL_COLOR, data=None))
    124     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/visitedShortest'), colorInfo.colorList[0], data=None))
    125     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/visitedLongest'), colorInfo.colorList[2], data=None))
    126 
    127 
    128 def ColorStarsBySecurity(colorInfo, starColorMode):
    129     starmap = sm.GetService('starmap')
    130     securitySvc = sm.GetService('securitySvc')
    131     for solarSystemID, solarSystem in starmap.GetKnownUniverseSolarSystems().iteritems():
    132         secStatus = securitySvc.get_modified_security_level(solarSystemID)
    133         colorInfo.solarSystemDict[solarSystemID] = (2,
    134          secStatus,
    135          None,
    136          None)
    137 
    138     colorInfo.colorList = COLORCURVE_SECURITY
    139     for i in xrange(0, 11):
    140         lbl = GetByLabel('UI/Map/StarModeHandler/securityLegendItem', level=1.0 - i * 0.1)
    141         colorInfo.legend.add(LegendItem(i, lbl, COLORCURVE_SECURITY[10 - i], data=None))
    142 
    143 
    144 def ColorStarsBySovChanges(colorInfo, starColorMode, changeMode):
    145     if changeMode == mapcommon.SOV_CHANGES_SOV_GAIN:
    146         color = trinity.TriColor(0.0, 1.0, 0.0)
    147     elif changeMode == mapcommon.SOV_CHANGES_SOV_LOST:
    148         color = trinity.TriColor(1.0, 0.0, 0.0)
    149     else:
    150         color = trinity.TriColor(0.9, 0.6, 0.1)
    151     changes = GetSovChangeList(changeMode)
    152     hintFunc = lambda comments: '<br><br>'.join(comments)
    153     for solarSystemID, comments in changes.iteritems():
    154         colorInfo.solarSystemDict[solarSystemID] = (len(comments) * 2.0,
    155          1.0,
    156          (hintFunc, (comments,)),
    157          color)
    158 
    159     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/sovereigntyNoSovChanges'), mapcommon.NEUTRAL_COLOR, None))
    160     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/sovereigntySovChanges'), color, None))
    161 
    162 
    163 def GetSovChangeList(changeMode):
    164     data = sm.GetService('sov').GetRecentActivity()
    165     changes = []
    166     resultMap = {}
    167     toPrime = set()
    168     for item in data:
    169         if item.stationID is None:
    170             if bool(changeMode & mapcommon.SOV_CHANGES_SOV_GAIN) and item.ownerID is not None:
    171                 changes.append((item.solarSystemID, 'UI/Map/StarModeHandler/sovereigntySovGained', (None, item.ownerID)))
    172                 toPrime.add(item.ownerID)
    173             elif bool(changeMode & mapcommon.SOV_CHANGES_SOV_LOST) and item.oldOwnerID is not None:
    174                 changes.append((item.solarSystemID, 'UI/Map/StarModeHandler/sovereigntySovLost', (item.oldOwnerID, None)))
    175                 toPrime.add(item.oldOwnerID)
    176 
    177     cfg.eveowners.Prime(list(toPrime))
    178     for solarSystemID, text, owners in changes:
    179         oldOwner = '' if owners[0] is None else cfg.eveowners.Get(owners[0]).ownerName
    180         owner = '' if owners[1] is None else cfg.eveowners.Get(owners[1]).ownerName
    181         if solarSystemID not in resultMap:
    182             resultMap[solarSystemID] = []
    183         resultMap[solarSystemID].append(GetByLabel(text, owner=owner, oldOwner=oldOwner))
    184 
    185     return resultMap
    186 
    187 
    188 def ColorStarsByFactionStandings(colorInfo, starColorMode):
    189     starmap = sm.GetService('starmap')
    190     colorByFaction = {}
    191     neutral = trinity.TriColor(*COLOR_STANDINGS_NEUTRAL)
    192     for factionID in starmap.GetAllFactionsAndAlliances():
    193         colorByFaction[factionID] = trinity.TriColor(*starmap.GetColorByStandings(factionID))
    194 
    195     lbl = GetByLabel('UI/Map/StarModeHandler/factionStandings')
    196     hintFunc = lambda : lbl
    197     for solarSystemID, solarSystem in starmap.GetKnownUniverseSolarSystems().iteritems():
    198         color = colorByFaction.get(solarSystem.factionID, neutral)
    199         colorInfo.solarSystemDict[solarSystemID] = (2.0,
    200          1.0,
    201          (hintFunc, ()),
    202          color)
    203 
    204     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/factionGoodStandings'), trinity.TriColor(*COLOR_STANDINGS_GOOD), data=None))
    205     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/factionNeutralStandings'), trinity.TriColor(*COLOR_STANDINGS_NEUTRAL), data=None))
    206     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/factionBadStandings'), trinity.TriColor(*COLOR_STANDINGS_BAD), data=None))
    207 
    208 
    209 def ColorStarsByFaction(colorInfo, starColorMode):
    210     factionID = starColorMode[1]
    211     starmap = sm.GetService('starmap')
    212     allianceSolarSystems = starmap.GetAllianceSolarSystems()
    213     sovBySolarSystemID = {}
    214     toPrime = set()
    215     for solarSystemID, solarSystem in starmap.GetKnownUniverseSolarSystems().iteritems():
    216         if factionID == mapcommon.STARMODE_FILTER_EMPIRE:
    217             secClass = starmap.map.GetSecurityStatus(solarSystemID)
    218             if not idCheckers.IsFaction(solarSystem.factionID) or secClass == const.securityClassZeroSec:
    219                 continue
    220         sovHolderID = starmap._GetFactionIDFromSolarSystem(allianceSolarSystems, solarSystemID)
    221         if sovHolderID is None:
    222             continue
    223         if factionID >= 0 and sovHolderID != factionID:
    224             continue
    225         sovBySolarSystemID[solarSystemID] = sovHolderID
    226         toPrime.add(sovHolderID)
    227 
    228     cfg.eveowners.Prime(list(toPrime))
    229     hintFunc = lambda name: GetByLabel('UI/Map/StarModeHandler/factionSovereignty', name=name)
    230     for solarSystemID, sovHolderID in sovBySolarSystemID.iteritems():
    231         name = cfg.eveowners.Get(sovHolderID).name
    232         col = starmap.GetFactionOrAllianceColor(sovHolderID)
    233         colorInfo.solarSystemDict[solarSystemID] = (2.0,
    234          0.0,
    235          (hintFunc, (name,)),
    236          col)
    237         colorInfo.legend.add(LegendItem(None, name, col, data=sovHolderID))
    238 
    239 
    240 def ColorStarsByMilitia(colorInfo, starColorMode):
    241     factionID = starColorMode[1]
    242     if factionID < -1:
    243         return
    244     starmap = sm.GetService('starmap')
    245     fwVictoryPointSvc = sm.GetService('fwVictoryPointSvc')
    246     warFactions = GetOccupierFWFactions()
    247     colByFaction = {fID:starmap.GetFactionOrAllianceColor(fID) for fID in warFactions}
    248     nameByFaction = {fID:cfg.eveowners.Get(fID).name for fID in warFactions}
    249     maxPointsByFaction = {fID:1 for fID in warFactions}
    250     maxThresholdByFaction = {fID:1 for fID in warFactions}
    251     occupiedSystems = {}
    252     occupationStatesBySolarsystemByWarzone = sm.GetService('fwWarzoneSvc').GetAllOccupationStates()
    253     for occupationStatesBySolarsystem in occupationStatesBySolarsystemByWarzone.itervalues():
    254         for solarsystemID, occupationState in occupationStatesBySolarsystem.iteritems():
    255             if occupationState.occupierID == factionID or factionID == -1:
    256                 victoryPointState = fwVictoryPointSvc.GetVictoryPointState(solarsystemID)
    257                 if victoryPointState is not None:
    258                     maxThresholdByFaction[occupationState.occupierID] = max(victoryPointState.threshold, maxThresholdByFaction[occupationState.occupierID])
    259                     maxPointsByFaction[occupationState.occupierID] = max(victoryPointState.score, maxPointsByFaction[occupationState.occupierID])
    260                     occupiedSystems[solarsystemID] = (occupationState.occupierID, victoryPointState)
    261 
    262     hintFunc = lambda name, status: GetByLabel('UI/Map/StarModeHandler/militiaSystemStatus', name=name, status=status)
    263     multiplierByFaction = {fID:max(1.0, maxThresholdByFaction[fID] / maxPointsByFaction[fID]) for fID in maxThresholdByFaction.keys()}
    264     for particleID, solarSystemID in starmap.particleIDToSystemIDMap.iteritems():
    265         if solarSystemID in occupiedSystems:
    266             solarsystem = starmap.map.GetItem(solarSystemID)
    267             if solarsystem is None:
    268                 continue
    269             occupierID, victoryPointState = occupiedSystems[solarSystemID]
    270             age = multiplierByFaction[occupierID] * float(victoryPointState.score)
    271             size = 2.0 + pow(age, 0.35)
    272             statusText = GetVictoryPointStateText(victoryPointState)
    273             colorInfo.solarSystemDict[solarSystemID] = (size,
    274              age,
    275              (hintFunc, (nameByFaction[occupierID], statusText)),
    276              colByFaction[occupierID])
    277             colorInfo.legend.add(LegendItem(None, nameByFaction[occupierID], colByFaction[occupierID], data=occupierID))
    278             colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.0))
    279 
    280 
    281 def ColorStarsByRegion(colorInfo, starColorMode):
    282     starmap = sm.GetService('starmap')
    283     hintFunc = lambda name: GetByLabel('UI/Map/StarModeHandler/regionNameEntry', name=name)
    284     for regionID, region in starmap.GetKnownUniverseRegions().iteritems():
    285         regionName = cfg.evelocations.Get(regionID).name
    286         col = starmap.GetRegionColor(regionID)
    287         for solarSystemID in region.solarSystemIDs:
    288             colorInfo.solarSystemDict[solarSystemID] = (2,
    289              1.0,
    290              (hintFunc, (regionName,)),
    291              col)
    292 
    293         colorInfo.legend.add(LegendItem(None, regionName, col, data=regionID))
    294 
    295 
    296 def HintCargoIllegality(attackTypeIDs, confiscateTypeIDs):
    297     systemDescription = ''
    298     for typeID in attackTypeIDs:
    299         if systemDescription != '':
    300             systemDescription += '<br>'
    301         systemDescription += GetByLabel('UI/Map/StarModeHandler/legalityAttackHint', stuff=evetypes.GetName(typeID))
    302 
    303     for typeID in confiscateTypeIDs:
    304         if systemDescription != '':
    305             systemDescription += '<br>'
    306         systemDescription += GetByLabel('UI/Map/StarModeHandler/legalityConfiscateHint', item=evetypes.GetName(typeID))
    307 
    308     return systemDescription
    309 
    310 
    311 def ColorStarsByCargoIllegality(colorInfo, starColorMode):
    312     starmap = sm.GetService('starmap')
    313     invCache = sm.GetService('invCache')
    314     CONFISCATED_COLOR = trinity.TriColor(0.8, 0.4, 0.0)
    315     ATTACKED_COLOR = trinity.TriColor(1.0, 0.0, 0.0)
    316     invCache = sm.GetService('invCache')
    317     activeShipID = eveCfg.GetActiveShip()
    318     if activeShipID is None:
    319         shipCargo = []
    320     else:
    321         inv = invCache.GetInventoryFromId(activeShipID, locationID=session.stationid)
    322         shipCargo = inv.List()
    323     factionIllegality = {}
    324     while len(shipCargo) > 0:
    325         item = shipCargo.pop(0)
    326         if item.groupID in [const.groupCargoContainer,
    327          const.groupSecureCargoContainer,
    328          const.groupAuditLogSecureContainer,
    329          const.groupFreightContainer]:
    330             shipCargo.extend(invCache.GetInventoryFromId(item.itemID).List())
    331         itemIllegalities = inventorycommon.typeHelpers.GetIllegality(item.typeID)
    332         if itemIllegalities:
    333             for factionID, illegality in itemIllegalities.iteritems():
    334                 if factionID not in factionIllegality:
    335                     factionIllegality[factionID] = {}
    336                 if item.typeID not in factionIllegality[factionID]:
    337                     factionIllegality[factionID][item.typeID] = [max(0.0, illegality.confiscateMinSec), max(0.0, illegality.attackMinSec)]
    338 
    339     for solarSystemID, solarSystem in starmap.GetKnownUniverseSolarSystems().iteritems():
    340         colour = None
    341         factionID = solarSystem.factionID
    342         if factionID is None or factionID not in factionIllegality:
    343             continue
    344         systemIllegality = False
    345         attackTypeIDs = []
    346         confiscateTypeIDs = []
    347         securityStatus = starmap.map.GetSecurityStatus(solarSystemID)
    348         for typeID in factionIllegality[factionID]:
    349             if securityStatus >= factionIllegality[factionID][typeID][1]:
    350                 systemIllegality = True
    351                 if not colour or colour[0] < 2:
    352                     colour = (2, ATTACKED_COLOR)
    353                 attackTypeIDs.append(typeID)
    354             elif securityStatus >= factionIllegality[factionID][typeID][0]:
    355                 systemIllegality = True
    356                 if not colour:
    357                     colour = (1, CONFISCATED_COLOR)
    358                 confiscateTypeIDs.append(typeID)
    359 
    360         if systemIllegality:
    361             colorInfo.solarSystemDict[solarSystemID] = (3.0,
    362              0.0,
    363              (HintCargoIllegality, (attackTypeIDs, confiscateTypeIDs)),
    364              colour[1])
    365 
    366     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/legalityNoConsequences'), mapcommon.NEUTRAL_COLOR, data=None))
    367     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/legalityConfiscate'), CONFISCATED_COLOR, data=None))
    368     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/legalityWillAttack'), ATTACKED_COLOR, data=None))
    369 
    370 
    371 def ColorStarsByNumPilots(colorInfo, starColorMode):
    372     starmap = sm.GetService('starmap')
    373     maxCount = 0
    374     total = 0
    375     multiplier = 1.0
    376     infoOnPilotsBySolarSystemIDs = sm.GetService('map').GetInfoOnPilotsBySolarSystemIDs()
    377     pilotcountDict = {}
    378     for solarSystemID, info in infoOnPilotsBySolarSystemIDs.iteritems():
    379         if starColorMode == mapcommon.STARMODE_PLAYERCOUNT:
    380             amount = info.amountInSpace
    381         else:
    382             amount = info.amountDocked
    383         pilotcountDict[solarSystemID] = amount
    384         total = total + amount
    385         if amount > maxCount:
    386             maxCount = amount
    387 
    388     if maxCount > 0:
    389         multiplier /= math.sqrt(maxCount)
    390     sorted = pilotcountDict.values()
    391     sorted.sort()
    392     if starColorMode == mapcommon.STARMODE_PLAYERCOUNT:
    393         hintFunc = lambda count, solarSystemID: GetByLabel('UI/Map/StarModeHandler/pilotsInSpace', count=count, solarSystem=solarSystemID)
    394     else:
    395         hintFunc = lambda count, solarSystemID: GetByLabel('UI/Map/StarModeHandler/pilotsInStation', count=count, solarSystem=solarSystemID)
    396     for solarSystemID, pilotCount in pilotcountDict.iteritems():
    397         if pilotCount == 0:
    398             continue
    399         size = 2 * math.sqrt(pilotCount)
    400         colorInfo.solarSystemDict[solarSystemID] = (size,
    401          math.sqrt(pilotCount) * multiplier,
    402          (hintFunc, (pilotCount, solarSystemID)),
    403          None)
    404 
    405     colorInfo.colorList = ((0.25, 0.25, 0.0, 1.0), (0.5, 0.0, 0.0, 1.0))
    406     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
    407     startColor = starmap.GetColorCurveValue(colorCurve, multiplier)
    408     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/pilotsNone'), mapcommon.NEUTRAL_COLOR, data=None))
    409     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/pilotsOne'), startColor, data=None))
    410     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/pilotsMany', maxCount=maxCount), colorInfo.colorList[-1], data=None))
    411 
    412 
    413 def ColorStarsByStationCount(colorInfo, starColorMode):
    414     starmap = sm.GetService('starmap')
    415     if starmap.stationCountCache is None:
    416         starmap.stationCountCache = sm.RemoteSvc('map').GetStationCount()
    417     history = starmap.stationCountCache
    418     maxCount = 0
    419     for solarSystemID, amount in history:
    420         if amount > maxCount:
    421             maxCount = amount
    422 
    423     multiplier = 0
    424     if maxCount > 0:
    425         multiplier = 1.0 / float(maxCount)
    426     hintFunc = lambda count, solarSystemID: GetByLabel('UI/Map/StarModeHandler/stationsCount', count=count, solarSystem=solarSystemID)
    427     for solarSystemID, amount in history:
    428         age = multiplier * float(amount)
    429         size = 2.0 + pow(age, 0.5) * 4.0
    430         colorInfo.solarSystemDict[solarSystemID] = (size,
    431          age,
    432          (hintFunc, (amount, solarSystemID)),
    433          None)
    434 
    435     colorInfo.colorList = ((0.5, 0.32, 0.0, 1.0), (0.7, 0.0, 0.0, 1.0))
    436     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
    437     startColor = starmap.GetColorCurveValue(colorCurve, multiplier)
    438     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/stationsNone'), mapcommon.NEUTRAL_COLOR, data=None))
    439     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/stationsOne'), startColor, data=None))
    440     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/stationsMany', maxCount=maxCount), colorInfo.colorList[-1], data=None))
    441 
    442 
    443 def HintDungeons(dungeons):
    444     comments = []
    445     for dungeonID, difficulty, dungeonName in dungeons:
    446         ded = ''
    447         if difficulty:
    448             ded = GetByLabel('UI/Map/StarModeHandler/dungeonDedDiffaculty', count=difficulty)
    449         comments.append(GetByLabel('UI/Map/StarModeHandler/dungeonDedLegendHint', dungeonName=dungeonName, dedName=ded))
    450 
    451     return '<br>'.join(comments)
    452 
    453 
    454 def ColorStarsByDungeons(colorInfo, starColorMode):
    455     starmap = sm.GetService('starmap')
    456     if starColorMode == mapcommon.STARMODE_DUNGEONS:
    457         dungeons = sm.RemoteSvc('map').GetDeadspaceComplexMap(session.languageID)
    458     elif starColorMode == mapcommon.STARMODE_DUNGEONSAGENTS:
    459         dungeons = sm.RemoteSvc('map').GetDeadspaceAgentsMap(session.languageID)
    460     if dungeons is None:
    461         return
    462     solmap = {}
    463     for solarSystemID, dungeonID, difficulty, dungeonName in dungeons:
    464         if solarSystemID in solmap:
    465             solmap[solarSystemID].append((dungeonID, difficulty, dungeonName))
    466         else:
    467             solmap[solarSystemID] = [(dungeonID, difficulty, dungeonName)]
    468 
    469     for solarSystemID, solarSystemDungeons in solmap.iteritems():
    470         maxDifficulty = 1
    471         for dungeonID, difficulty, dungeonName in solarSystemDungeons:
    472             if difficulty:
    473                 maxDifficulty = max(maxDifficulty, difficulty)
    474 
    475         maxDifficulty = (10 - maxDifficulty) / 9.0
    476         colorInfo.solarSystemDict[solarSystemID] = (3.0 * len(solarSystemDungeons),
    477          maxDifficulty,
    478          (HintDungeons, (solarSystemDungeons,)),
    479          None)
    480 
    481     colorInfo.colorList = COLORCURVE_SECURITY
    482     colorCurve = starmap.GetColorCurve(COLORCURVE_SECURITY)
    483     for i in xrange(0, 10):
    484         lbl = GetByLabel('UI/Map/StarModeHandler/dungeonDedLegendDiffaculty', difficulty=i + 1)
    485         colorInfo.legend.add(LegendItem(i, lbl, starmap.GetColorCurveValue(colorCurve, (9 - i) / 9.0), data=None))
    486 
    487 
    488 def ColorStarsByJumps1Hour(colorInfo, starColorMode):
    489     starmap = sm.GetService('starmap')
    490     historyDB = sm.RemoteSvc('map').GetHistory(const.mapHistoryStatJumps, 1)
    491     history = []
    492     for entry in historyDB:
    493         if entry.value1 > 0:
    494             history.append((entry.solarSystemID, entry.value1))
    495 
    496     maxCount = 0
    497     for solarSystemID, amount in history:
    498         if amount > maxCount:
    499             maxCount = amount
    500 
    501     if maxCount > 1:
    502         divisor = 1.0 / math.log(pow(float(maxCount), 4.0))
    503         hintFunc = lambda count, solarSystemID: GetByLabel('UI/Map/StarModeHandler/JumpsLastHour', count=count, solarSystem=solarSystemID)
    504         for solarSystemID, amount in history:
    505             age = divisor * math.log(pow(float(amount), 4.0))
    506             size = 2.0 + pow(age, 0.5) * 2.0
    507             colorInfo.solarSystemDict[solarSystemID] = (size,
    508              age,
    509              (hintFunc, (amount, solarSystemID)),
    510              None)
    511 
    512     colorInfo.colorList = (trinity.TriColor(0.0, 0.0, 1.0),
    513      trinity.TriColor(0.0, 1.0, 1.0),
    514      trinity.TriColor(1.0, 1.0, 0.0),
    515      trinity.TriColor(1.0, 0.0, 0.0))
    516     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/jumpsNumber', count=0), colorInfo.colorList[0], data=None))
    517     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/jumpsNumber', count=maxCount), colorInfo.colorList[-1], data=None))
    518 
    519 
    520 def ColorStarsByKills(colorInfo, starColorMode, statID, hours):
    521     starmap = sm.GetService('starmap')
    522     historyDB = sm.RemoteSvc('map').GetHistory(statID, hours)
    523     history = []
    524     for entry in historyDB:
    525         if entry.value1 - entry.value2 > 0:
    526             history.append((entry.solarSystemID, entry.value1 - entry.value2))
    527 
    528     maxCount = 0
    529     for solarSystemID, amount in history:
    530         if amount > maxCount:
    531             maxCount = amount
    532 
    533     if maxCount > 0:
    534         divisor = 1.0 / float(maxCount)
    535     hintFunc = lambda count, solarSystemID, hours: GetByLabel('UI/Map/StarModeHandler/killsShipsInLast', count=count, solarSystem=solarSystemID, hours=hours)
    536     for solarSystemID, amount in history:
    537         age = divisor * float(amount)
    538         size = 2.0 + pow(amount, 0.5) * 4.0
    539         colorInfo.solarSystemDict[solarSystemID] = (size,
    540          age,
    541          (hintFunc, (amount, solarSystemID, hours)),
    542          None)
    543 
    544     colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
    545     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/killsNumber', count=0), colorInfo.colorList[0], data=None))
    546     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/killsNumber', count=maxCount), colorInfo.colorList[-1], data=None))
    547 
    548 
    549 def ColorStarsByPodKills(colorInfo, starColorMode):
    550     starmap = sm.GetService('starmap')
    551     if starColorMode == mapcommon.STARMODE_PODKILLS24HR:
    552         hours = 24
    553         historyDB = sm.RemoteSvc('map').GetHistory(const.mapHistoryStatKills, 24)
    554     else:
    555         hours = 1
    556         historyDB = sm.RemoteSvc('map').GetHistory(const.mapHistoryStatKills, 1)
    557     history = []
    558     for entry in historyDB:
    559         if entry.value3 > 0:
    560             history.append((entry.solarSystemID, entry.value3))
    561 
    562     maxCount = 0
    563     for solarSystemID, amount in history:
    564         if amount > maxCount:
    565             maxCount = amount
    566 
    567     divisor = 0.0
    568     if maxCount > 0:
    569         divisor = 1.0 / float(maxCount)
    570     hintFunc = lambda solarSystemID, hours, count: GetByLabel('UI/Map/StarModeHandler/killsPodInLast', solarSystem=solarSystemID, hours=hours, count=count)
    571     for solarSystemID, amount in history:
    572         age = divisor * float(amount)
    573         size = 2.0 + pow(amount, 0.5) * 4.0
    574         colorInfo.solarSystemDict[solarSystemID] = (size,
    575          age,
    576          (hintFunc, (solarSystemID, hours, amount)),
    577          None)
    578 
    579     colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
    580     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/killsPodNumber', count=0), colorInfo.colorList[0], data=None))
    581     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/killsPodNumber', count=maxCount), colorInfo.colorList[-1], data=None))
    582 
    583 
    584 def ColorStarsByFactionKills(colorInfo, starColorMode):
    585     starmap = sm.GetService('starmap')
    586     hours = 24
    587     historyDB = sm.RemoteSvc('map').GetHistory(const.mapHistoryStatKills, hours)
    588     history = []
    589     for entry in historyDB:
    590         if entry.value2 > 0:
    591             history.append((entry.solarSystemID, entry.value2))
    592 
    593     maxCount = 0
    594     for solarSystemID, amount in history:
    595         if amount > maxCount:
    596             maxCount = amount
    597 
    598     divisor = 0.0
    599     if maxCount > 0:
    600         divisor = 1.0 / float(maxCount)
    601     hintFunc = lambda solarSystemID, hours, count: GetByLabel('UI/Map/StarModeHandler/killsFactionInLast', solarSystem=solarSystemID, hours=hours, count=count)
    602     for solarSystemID, amount in history:
    603         age = divisor * float(amount)
    604         size = 1.0 + math.log(amount) * 2.0
    605         colorInfo.solarSystemDict[solarSystemID] = (size,
    606          age,
    607          (hintFunc, (solarSystemID, hours, amount)),
    608          None)
    609 
    610     colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
    611     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/killsNumber', count=0), colorInfo.colorList[0], data=None))
    612     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/killsNumber', count=maxCount), colorInfo.colorList[-1], data=None))
    613 
    614 
    615 def ColorStarsByBookmarks(colorInfo, starColorMode):
    616     starmap = sm.GetService('starmap')
    617     bms = sm.GetService('bookmarkSvc').GetAllBookmarks()
    618     highlightSystems = {}
    619     for bookmark in bms.itervalues():
    620         item = starmap.map.GetItem(bookmark.locationID)
    621         if item is not None and item.typeID == const.typeSolarSystem:
    622             solarSystemID = bookmark.locationID
    623         else:
    624             solarSystemID = bookmark.itemID
    625         memo = bookmark.memo
    626         comment = None
    627         if len(memo):
    628             tabindex = string.find(memo, '\t')
    629             if tabindex != -1:
    630                 comment = memo[:tabindex]
    631         if solarSystemID not in highlightSystems:
    632             highlightSystems[solarSystemID] = [comment]
    633         else:
    634             highlightSystems[solarSystemID].append(comment)
    635 
    636     for system, comments in highlightSystems.iteritems():
    637         colorInfo.solarSystemDict[system] = (4,
    638          1.0,
    639          (lambda comments: '<br>'.join(filter(None, comments)), (comments,)),
    640          None)
    641 
    642     colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
    643     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/bookmarksNoneHere'), mapcommon.NEUTRAL_COLOR, data=None))
    644     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/bookmarksSomeHere'), colorInfo.colorList[-1], data=None))
    645 
    646 
    647 def ColorStarsByCynosuralFields(colorInfo, starColorMode):
    648     starmap = sm.GetService('starmap')
    649     fleetBeaconCount = sm.RemoteSvc('map').GetBeaconCount()
    650     solarSystemsWithBeacons = sm.GetService('structureDirectory').GetSolarSystemsWithBeacons()
    651     orange = trinity.TriColor(1.0, 0.4, 0.0, 1.0)
    652     green = trinity.TriColor(0.2, 1.0, 1.0, 1.0)
    653     red = trinity.TriColor(1.0, 0.0, 0.0, 1.0)
    654     hintFuncTotal = lambda count: GetByLabel('UI/Map/StarModeHandler/cynoActiveFieldsGeneratorsNumber', count=count)
    655     hintFuncModule = lambda count: GetByLabel('UI/Map/StarModeHandler/cynoActiveFieldsNumber', count=count)
    656     hintFuncStructure = lambda count: GetByLabel('UI/Map/StarModeHandler/cynoActiveGeneratorNumber', count=count)
    657     allSolarSystemIDs = set(fleetBeaconCount.keys()).union(solarSystemsWithBeacons)
    658     for solarSystemID in allSolarSystemIDs:
    659         moduleCnt = fleetBeaconCount.get(solarSystemID, 0)
    660         structureCnt = 1 if solarSystemID in solarSystemsWithBeacons else 0
    661         if moduleCnt > 0 and structureCnt > 0:
    662             ttlcnt = moduleCnt + structureCnt
    663             colorInfo.solarSystemDict[solarSystemID] = (4 * ttlcnt,
    664              1.0,
    665              (hintFuncTotal, (ttlcnt,)),
    666              red)
    667         elif moduleCnt:
    668             colorInfo.solarSystemDict[solarSystemID] = (4 * moduleCnt,
    669              1.0,
    670              (hintFuncModule, (moduleCnt,)),
    671              green)
    672         elif structureCnt:
    673             colorInfo.solarSystemDict[solarSystemID] = (4 * structureCnt,
    674              1.0,
    675              (hintFuncStructure, (structureCnt,)),
    676              orange)
    677 
    678     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/cynoNoFieldsGenerators'), mapcommon.NEUTRAL_COLOR, data=None))
    679     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/cynoActiveFields'), green, data=None))
    680     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/cynoActiveGenerators'), orange, data=None))
    681     colorInfo.legend.add(LegendItem(3, GetByLabel('UI/Map/StarModeHandler/cynoActiveFieldsGenerators'), red, data=None))
    682 
    683 
    684 def ColorStarsByCorpAssets(colorInfo, starColorMode, assetKey, legendName):
    685     rows = sm.RemoteSvc('corpmgr').GetAssetInventory(session.corpid, assetKey)
    686     solarsystems = {}
    687     stuffToPrime = []
    688     for row in rows:
    689         stationID = row.locationID
    690         try:
    691             solarsystemID = sm.GetService('ui').GetStationStaticInfo(row.locationID).solarSystemID
    692         except:
    693             solarsystemID = row.locationID
    694 
    695         if solarsystemID not in solarsystems:
    696             solarsystems[solarsystemID] = {}
    697             stuffToPrime.append(solarsystemID)
    698         if stationID not in solarsystems[solarsystemID]:
    699             solarsystems[solarsystemID][stationID] = []
    700             stuffToPrime.append(stationID)
    701         solarsystems[solarsystemID][stationID].append(row)
    702 
    703     cfg.evelocations.Prime(stuffToPrime)
    704     hintFunc = lambda stationIDs: '<br>'.join([ cfg.evelocations.Get(stationID).name for stationID in stationIDs ])
    705     for solarsystemID, stations in solarsystems.iteritems():
    706         total = 100000
    707         color = trinity.TriColor(1.0, 0.8, 0.0, 1.0)
    708         size = 4.0 + math.log10(total)
    709         colorInfo.solarSystemDict[solarsystemID] = (size,
    710          1.0,
    711          (hintFunc, (stations.keys(),)),
    712          color)
    713 
    714     colorInfo.colorList = (trinity.TriColor(0.25, 0.25, 0.0), trinity.TriColor(0.5, 0.1, 0.0))
    715     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/corpNoAssets'), mapcommon.NEUTRAL_COLOR, data=None))
    716     colorInfo.legend.add(LegendItem(1, legendName, colorInfo.colorList[-1], data=None))
    717 
    718 
    719 def ColorStarsByServices(colorInfo, starColorMode):
    720     starmap = sm.GetService('starmap')
    721     serviceTypeID = starColorMode[1]
    722     stations = sm.RemoteSvc('map').GetStationInfo()
    723     stationIDs = []
    724     solarsystems = {}
    725     if starmap.warFactionByOwner is None and serviceTypeID == const.stationServiceNavyOffices:
    726         starmap.warFactionByOwner = {}
    727         for stationRow in stations:
    728             ownerID = stationRow.ownerID
    729             if ownerID not in starmap.warFactionByOwner:
    730                 factionID = get_corporation_faction_id(ownerID)
    731                 if factionID and IsAnyFWFaction(factionID):
    732                     starmap.warFactionByOwner[ownerID] = factionID
    733 
    734     if serviceTypeID == const.stationServiceSecurityOffice:
    735         secOfficeSvc = sm.GetService('securityOfficeSvc')
    736     for stationRow in stations:
    737         solarSystemID = stationRow.solarSystemID
    738         if stationRow.operationID == None:
    739             continue
    740         if not service_in_station_operation(stationRow.operationID, serviceTypeID):
    741             continue
    742         if serviceTypeID == const.stationServiceNavyOffices and stationRow.ownerID not in starmap.warFactionByOwner:
    743             continue
    744         if serviceTypeID == const.stationServiceSecurityOffice and not secOfficeSvc.CanAccessServiceInStation(stationRow.stationID):
    745             continue
    746         if solarSystemID not in solarsystems:
    747             solarsystems[solarSystemID] = []
    748         solarsystems[solarSystemID].append(stationRow.stationID)
    749         stationIDs.append(stationRow.stationID)
    750 
    751     cfg.evelocations.Prime(stationIDs)
    752     red = trinity.TriColor(1.0, 0.0, 0.0, 1.0)
    753     hintFunc = lambda stationIDs: '<br>'.join([ cfg.evelocations.Get(stationID).name for stationID in stationIDs ])
    754 
    755     def hintFunc2(stationIDs):
    756         hint = ''
    757         for stationID in stationIDs:
    758             station = sm.StartService('ui').GetStationStaticInfo(stationID)
    759             stationName = cfg.evelocations.Get(stationID).name
    760             stationTypeID = station.stationTypeID
    761             if hint:
    762                 hint += '<br>'
    763             hint += '- <url=showinfo:%d//%d>%s</url>' % (stationTypeID, stationID, stationName)
    764 
    765         return hint
    766 
    767     for solarsystemID, stationIDs in solarsystems.iteritems():
    768         colorInfo.solarSystemDict[solarsystemID] = (4.0,
    769          1.0,
    770          (hintFunc2, (stationIDs,)),
    771          red)
    772 
    773     colorInfo.colorList = (trinity.TriColor(0.25, 0.25, 0.0), trinity.TriColor(0.5, 0.1, 0.0))
    774     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/serviceNoneHere'), mapcommon.NEUTRAL_COLOR, data=None))
    775     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/serviceHasServices'), red, data=None))
    776 
    777 
    778 def ColorStarsByFleetMembers(colorInfo, starColorMode):
    779     fleetComposition = sm.GetService('fleet').GetFleetComposition()
    780     if fleetComposition is not None:
    781         solarsystems = {}
    782         for each in fleetComposition:
    783             if each.solarSystemID not in solarsystems:
    784                 solarsystems[each.solarSystemID] = []
    785             solarsystems[each.solarSystemID].append(each.characterID)
    786 
    787         hintFunc = lambda characterIDs: '<br>'.join([ cfg.eveowners.Get(characterID).name for characterID in characterIDs ])
    788         for locationID, charIDs in solarsystems.iteritems():
    789             colorInfo.solarSystemDict[locationID] = (4.0,
    790              1.0,
    791              (hintFunc, (charIDs,)),
    792              DEFAULT_MAX_COLOR)
    793 
    794     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/fleetNoMembers'), mapcommon.NEUTRAL_COLOR, data=None))
    795     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/fleetHasMembers'), DEFAULT_MAX_COLOR, data=None))
    796 
    797 
    798 def ColorStarsByCorpMembers(colorInfo, starColorMode):
    799     corp = sm.RemoteSvc('map').GetMyExtraMapInfo()
    800     if corp is not None:
    801         solarsystems = {}
    802         for each in corp:
    803             if each.locationID not in solarsystems:
    804                 solarsystems[each.locationID] = []
    805             solarsystems[each.locationID].append(each.characterID)
    806 
    807         hintFunc = lambda characterIDs: '<br>'.join([ cfg.eveowners.Get(characterID).name for characterID in characterIDs ])
    808         for locationID, charIDs in solarsystems.iteritems():
    809             colorInfo.solarSystemDict[locationID] = (4,
    810              1.0,
    811              (hintFunc, (charIDs,)),
    812              DEFAULT_MAX_COLOR)
    813 
    814     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/corpNoMembers'), mapcommon.NEUTRAL_COLOR, data=None))
    815     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/corpHasMembers'), DEFAULT_MAX_COLOR, data=None))
    816 
    817 
    818 def HintMyAgents(stations):
    819     caption = ''
    820     for stationID, agents in stations.iteritems():
    821         for agent in agents:
    822             agentOwner = cfg.eveowners.Get(agent.agentID)
    823             agentString = GetByLabel('UI/Map/StarModeHandler/agentCaptionDetails', divisionName=get_division_name(agent.divisionID), agentName=agentOwner.name, level=agent.level)
    824             if caption:
    825                 caption += '<br>'
    826             caption += '- <url=showinfo:%d//%d>%s</url>' % (agentOwner.typeID, agent.agentID, agentString)
    827 
    828     return caption
    829 
    830 
    831 def ColorStarsByMyAgents(colorInfo, starColorMode):
    832     standingInfo = sm.RemoteSvc('map').GetMyExtraMapInfoAgents().Index('fromID')
    833     solarsystems = {}
    834     valid = (const.agentTypeBasicAgent, const.agentTypeResearchAgent, const.agentTypeFactionalWarfareAgent)
    835     agentsByID = sm.GetService('agents').GetAgentsByID()
    836     facWarService = sm.GetService('facwar')
    837     skills = {}
    838     for agentID in agentsByID:
    839         agent = agentsByID[agentID]
    840         fa = standingInfo.get(agent.factionID, 0.0)
    841         if fa:
    842             fa = fa.rank * 10.0
    843         co = standingInfo.get(agent.corporationID, 0.0)
    844         if co:
    845             co = co.rank * 10.0
    846         ca = standingInfo.get(agent.agentID, 0.0)
    847         if ca:
    848             ca = ca.rank * 10.0
    849         isLimitedToFacWar = False
    850         if agent.agentTypeID == const.agentTypeFactionalWarfareAgent and facWarService.GetCorporationWarFactionID(agent.corporationID) != session.warfactionid:
    851             isLimitedToFacWar = True
    852         if agent.agentTypeID in valid and eveCfg.CanUseAgent(agent.level, agent.agentTypeID, fa, co, ca, agent.corporationID, agent.factionID, skills) and isLimitedToFacWar == False:
    853             if agent.stationID:
    854                 if agent.solarsystemID not in solarsystems:
    855                     solarsystems[agent.solarsystemID] = {}
    856                 if agent.stationID not in solarsystems[agent.solarsystemID]:
    857                     solarsystems[agent.solarsystemID][agent.stationID] = []
    858                 solarsystems[agent.solarsystemID][agent.stationID].append(agent)
    859 
    860     hintFunc = HintMyAgents
    861     for solarsystemID, stations in solarsystems.iteritems():
    862         totalAgents = sum((len(agents) for agents in stations.itervalues()))
    863         colorInfo.solarSystemDict[solarsystemID] = (int(totalAgents),
    864          1.0,
    865          (hintFunc, (stations,)),
    866          DEFAULT_MAX_COLOR)
    867 
    868     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/agentNoneHere'), mapcommon.NEUTRAL_COLOR, data=None))
    869     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/agentSomeHere'), DEFAULT_MAX_COLOR, data=None))
    870 
    871 
    872 def HintMyJumpClones(clones):
    873     from evelink.client import location_link
    874     hintList = []
    875     for eachClone in clones:
    876         stationName = location_link(eachClone.location_id, link_text=uix.EditStationName(cfg.evelocations.Get(eachClone.location_id).name, usename=1))
    877         cloneHint = ' - %s - %s' % (eachClone.name, stationName)
    878         hintList.append(cloneHint)
    879 
    880     return '<br>'.join(hintList)
    881 
    882 
    883 def ColorStarsByJumpClones(colorInfo, starColorMode):
    884     bySystemID = GetJumpClonesBySystemID()
    885     hintFunc = HintMyJumpClones
    886     for solarsystemID, clones in bySystemID.iteritems():
    887         size = 3.0 + pow(len(clones), 0.5) * 4.0
    888         colorInfo.solarSystemDict[solarsystemID] = (size,
    889          1.0,
    890          (hintFunc, (clones,)),
    891          DEFAULT_MAX_COLOR)
    892 
    893 
    894 def ColorStarsByAvoidedSystems(colorInfo, starColorMode):
    895     avoidanceSolarSystemIDs = sm.GetService('clientPathfinderService').GetExpandedAvoidanceItems()
    896     red = trinity.TriColor(1.0, 0.0, 0.0)
    897     hintFunc = lambda : GetByLabel('UI/Map/StarModeHandler/advoidSystemOnList')
    898     for solarSystemID in avoidanceSolarSystemIDs:
    899         colorInfo.solarSystemDict[solarSystemID] = (1,
    900          1.0,
    901          (hintFunc, ()),
    902          red)
    903 
    904     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/advoidNotAdvoided'), mapcommon.NEUTRAL_COLOR, data=None))
    905     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/advoidAdvoided'), red, data=None))
    906 
    907 
    908 def ColorStarsByRealSunColor(colorInfo, starColorMode):
    909     starmap = sm.GetService('starmap')
    910     for solarSystemID, solarSystem in starmap.GetKnownUniverseSolarSystems().iteritems():
    911         colorInfo.solarSystemDict[solarSystemID] = (1,
    912          0.0,
    913          None,
    914          trinity.TriColor(*solarSystem.star.color))
    915 
    916     colorInfo.overglowFactor = mapcommon.ACTUAL_COLOR_OVERGLOWFACTOR
    917     for typeID, sunType in mapcommon.SUN_DATA.iteritems():
    918         name = evetypes.GetName(typeID)
    919         colorInfo.legend.add(LegendItem(name, name, trinity.TriColor(*sunType.color), data=None))
    920 
    921 
    922 def ColorStarsByPIScanRange(colorInfo, starColorMode):
    923     starmap = sm.GetService('starmap')
    924     playerLoc = cfg.evelocations.Get(session.solarsystemid2)
    925     playerPos = (playerLoc.x, playerLoc.y, playerLoc.z)
    926     remoteSensing = sm.GetService('skills').GetEffectiveLevel(appConst.typeRemoteSensing) or 0
    927     hintFunc = lambda range: GetByLabel('UI/Map/StarModeHandler/scanHintDistance', range=range)
    928     for particleID, solarSystemID in starmap.particleIDToSystemIDMap.iteritems():
    929         systemLoc = cfg.evelocations.Get(solarSystemID)
    930         systemPos = (systemLoc.x, systemLoc.y, systemLoc.z)
    931         dist = geo2.Vec3Distance(playerPos, systemPos) / appConst.LIGHTYEAR
    932         proximity = None
    933         for i, each in enumerate(appConst.planetResourceScanningRanges):
    934             if not i >= 5 - remoteSensing:
    935                 continue
    936             if each >= dist:
    937                 proximity = i
    938 
    939         if proximity is not None:
    940             colorInfo.solarSystemDict[solarSystemID] = (max(1, proximity),
    941              1.0 / 5.0 * proximity,
    942              (hintFunc, (dist,)),
    943              None)
    944 
    945     colorCurve = starmap.GetColorCurve(COLORCURVE_SECURITY)
    946     for i, each in enumerate(appConst.planetResourceScanningRanges):
    947         if not i >= 5 - remoteSensing:
    948             continue
    949         lbl = GetByLabel('UI/Map/StarModeHandler/scanLegendDistance', range=appConst.planetResourceScanningRanges[i])
    950         colorInfo.legend.add(LegendItem(i, lbl, starmap.GetColorCurveValue(colorCurve, 1.0 / 5.0 * i), data=None))
    951 
    952 
    953 def ColorStarsByPlanetType(colorInfo, starColorMode):
    954     planetTypeID = starColorMode[1]
    955     starmap = sm.GetService('starmap')
    956     systems = defaultdict(int)
    957     maxCount = 0
    958     for solarSystemID, d in starmap.GetKnownUniverseSolarSystems().iteritems():
    959         if planetTypeID in d.planetCountByType:
    960             systems[solarSystemID] = v = d.planetCountByType[planetTypeID]
    961             maxCount = max(maxCount, v)
    962         else:
    963             systems[solarSystemID] = 0
    964 
    965     if maxCount > 1:
    966         divisor = 1.0 / (maxCount - 1)
    967     else:
    968         divisor = 1.0
    969     planetTypeName = evetypes.GetName(planetTypeID)
    970     caption = planetTypeName + ': %d'
    971     hintFunc = lambda count: caption % count
    972     for solarSystemID, count in systems.iteritems():
    973         age = divisor * float(count)
    974         size = 2.0 + pow(count, 0.5) * 2.0
    975         colorInfo.solarSystemDict[solarSystemID] = (size,
    976          age,
    977          (hintFunc, (count,)),
    978          None)
    979 
    980     colorInfo.colorList = (trinity.TriColor(0.46, 0.34, 0.1), trinity.TriColor(0.3, 1.0, 0.3))
    981     if maxCount > 1:
    982         colorInfo.legend.add(LegendItem(0, caption % 1, colorInfo.colorList[0], data=None))
    983     colorInfo.legend.add(LegendItem(1, caption % maxCount, colorInfo.colorList[-1], data=None))
    984 
    985 
    986 def ColorStarsByMyColonies(colorInfo, starColorMode):
    987     planetSvc = sm.GetService('planetSvc')
    988     planetRows = planetSvc.GetMyPlanets()
    989     if len(planetRows):
    990         mapSvc = sm.GetService('map')
    991         systems = defaultdict(int)
    992         for row in planetRows:
    993             systems[row.solarSystemID] += 1
    994 
    995         maxCount = max(systems.itervalues())
    996         divisor = 1.0 if maxCount == 1 else 1.0 / (maxCount - 1)
    997         hintFunc = lambda count: GetByLabel('UI/Map/StarModeHandler/planetsColoniesCount', count=count)
    998         for solarSystemID, count in systems.iteritems():
    999             if maxCount > 1:
   1000                 age = divisor * float(count - 1)
   1001             else:
   1002                 age = 1.0
   1003             size = 2.0 + pow(count, 0.5) * 4.0
   1004             colorInfo.solarSystemDict[solarSystemID] = (size,
   1005              age,
   1006              (hintFunc, (count,)),
   1007              None)
   1008 
   1009         colorInfo.colorList = (trinity.TriColor(0.0, 0.22, 0.55), trinity.TriColor(0.2, 0.5, 1.0))
   1010         if maxCount > 1:
   1011             colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/planetsColoniesCount', count=1), colorInfo.colorList[0], data=None))
   1012         colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/planetsColoniesCount', count=maxCount), colorInfo.colorList[-1], data=None))
   1013 
   1014 
   1015 def ColorStarsByIncursions(colorInfo, starColorMode):
   1016     ms = session.ConnectToRemoteService('map')
   1017     participatingSystems = ms.GetSystemsInIncursions()
   1018     for solarSystem in participatingSystems:
   1019         colorInfo.solarSystemDict[solarSystem.locationID] = GetColorAndHintForIncursionSystem(solarSystem.sceneType, solarSystem.templateNameID)
   1020 
   1021     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/incursionStageing'), COLOR_YELLOW, data=None))
   1022     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/incursionPraticipant'), COLOR_ORANGE, data=None))
   1023 
   1024 
   1025 def _GetValueForInterferenceBand(interferenceBand):
   1026     if interferenceBand == INTERFERENCE_BAND_NONE:
   1027         return 0.0
   1028     if interferenceBand == INTERFERENCE_BAND_LOW:
   1029         return 33.0
   1030     if interferenceBand == INTERFERENCE_BAND_MEDIUM:
   1031         return 66.0
   1032     if interferenceBand == INTERFERENCE_BAND_HIGH:
   1033         return 100.0
   1034 
   1035 
   1036 def _GetInterferenceBandFromMapPlaceholderValue(placeholderValue):
   1037     high = _GetValueForInterferenceBand(INTERFERENCE_BAND_HIGH)
   1038     low = _GetValueForInterferenceBand(INTERFERENCE_BAND_LOW)
   1039     med = _GetValueForInterferenceBand(INTERFERENCE_BAND_MEDIUM)
   1040     if placeholderValue == high:
   1041         return INTERFERENCE_BAND_HIGH
   1042     if placeholderValue == low:
   1043         return INTERFERENCE_BAND_LOW
   1044     if placeholderValue == med:
   1045         return INTERFERENCE_BAND_MEDIUM
   1046     return INTERFERENCE_BAND_NONE
   1047 
   1048 
   1049 def ColorStarsByInterference(colorInfo, starColorMode, solarSystemInterferenceSvc):
   1050     starmap = sm.GetService('starmap')
   1051     interferenceBands = solarSystemInterferenceSvc.GetAllInterferenceBands()
   1052     maxInterference = _GetValueForInterferenceBand(INTERFERENCE_BAND_HIGH)
   1053     multiplier = 0
   1054     if maxInterference > 0:
   1055         multiplier = 1.0 / maxInterference
   1056     hintFunc = lambda interference, solarSystemID: GetByLabel('UI/Map/StarModeHandler/interference', interference=GetInterferenceBandLabel(_GetInterferenceBandFromMapPlaceholderValue(interference)))
   1057     for solarSystemID, interferenceBand in interferenceBands.iteritems():
   1058         interferenceBandValue = _GetValueForInterferenceBand(interferenceBand)
   1059         if interferenceBandValue == 0:
   1060             continue
   1061         size = 2 * math.sqrt(interferenceBandValue)
   1062         colorInfo.solarSystemDict[solarSystemID] = (size,
   1063          interferenceBandValue * multiplier,
   1064          (hintFunc, (interferenceBandValue, solarSystemID)),
   1065          None)
   1066 
   1067     colorInfo.colorList = ((0.5, 0.32, 0.0, 1.0), (0.7, 0.0, 0.0, 1.0))
   1068     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
   1069     startColor = starmap.GetColorCurveValue(colorCurve, multiplier)
   1070     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/NoInterference'), mapcommon.NEUTRAL_COLOR, data=None))
   1071     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/WeakInterference'), startColor, data=None))
   1072     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/StrongInterference'), colorInfo.colorList[-1], data=None))
   1073 
   1074 
   1075 def ColorStarsByInsurgencyCorruption(colorInfo, starColorMode, insurgencySvc, corruptionSuppressionSvc):
   1076     starmap = sm.GetService('starmap')
   1077     snapshots = insurgencySvc.GetCurrentCampaignSnapshots_Memoized()
   1078     insurgencyMapData = {}
   1079     nameData = {}
   1080     corruptionStages = {}
   1081 
   1082     def hintFun(solarsystemid):
   1083         factionName = nameData[solarsystemid]
   1084         return u'{}<br/>{}<br/>{}'.format(GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), factionName, GetByLabel('UI/PirateInsurgencies/stageLabel', stage=corruptionStages[solarsystemid]))
   1085 
   1086     for snapshot in snapshots:
   1087         for solarsystemid in snapshot.coveredSolarsystemIDs:
   1088             insurgencyMapData[solarsystemid] = 1.0
   1089             nameData[solarsystemid] = get_faction_name(snapshot.pirateFactionID)
   1090             systemData = corruptionSuppressionSvc.GetSystemCorruption(solarsystemid)
   1091             stage = systemData.stage
   1092             corruptionStages[solarsystemid] = stage
   1093             size = math.pow(stage, 2)
   1094             colorInfo.solarSystemDict[solarsystemid] = (size,
   1095              1,
   1096              (hintFun, (solarsystemid,)),
   1097              None)
   1098 
   1099     colorInfo.colorList = (mapcommon.NEUTRAL_COLOR, Color.HextoRGBA('#9EFF00'))
   1100     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
   1101     startColor = starmap.GetColorCurveValue(colorCurve, 1.0)
   1102     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/PirateInsurgencies/systemNotAffectedByInsurgency'), mapcommon.NEUTRAL_COLOR, data=None))
   1103     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), startColor, data=None))
   1104 
   1105 
   1106 def ColorStarsByInsurgencySuppression(colorInfo, starColorMode, insurgencySvc, corruptionSuppressionSvc):
   1107     starmap = sm.GetService('starmap')
   1108     snapshots = insurgencySvc.GetCurrentCampaignSnapshots_Memoized()
   1109     insurgencyMapData = {}
   1110     nameData = {}
   1111     suppressionStages = {}
   1112 
   1113     def hintFun(solarsystemid):
   1114         factionName = nameData[solarsystemid]
   1115         return u'{}<br/>{}<br/>{}'.format(GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), factionName, GetByLabel('UI/PirateInsurgencies/stageLabel', stage=suppressionStages[solarsystemid]))
   1116 
   1117     for snapshot in snapshots:
   1118         for solarsystemid in snapshot.coveredSolarsystemIDs:
   1119             insurgencyMapData[solarsystemid] = 1.0
   1120             nameData[solarsystemid] = get_faction_name(snapshot.pirateFactionID)
   1121             systemData = corruptionSuppressionSvc.GetSystemSuppression(solarsystemid)
   1122             stage = systemData.stage
   1123             suppressionStages[solarsystemid] = stage
   1124             size = math.pow(stage, 2)
   1125             colorInfo.solarSystemDict[solarsystemid] = (size,
   1126              1,
   1127              (hintFun, (solarsystemid,)),
   1128              None)
   1129 
   1130     colorInfo.colorList = (mapcommon.NEUTRAL_COLOR, eveColor.WHITE)
   1131     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
   1132     startColor = starmap.GetColorCurveValue(colorCurve, 1.0)
   1133     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/PirateInsurgencies/systemNotAffectedByInsurgency'), mapcommon.NEUTRAL_COLOR, data=None))
   1134     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), startColor, data=None))
   1135 
   1136 
   1137 def ColorStarsByInsurgencyInvolvement(colorInfo, starColorMode, insurgencySvc, corruptionSuppressionSvc):
   1138     starmap = sm.GetService('starmap')
   1139     snapshots = insurgencySvc.GetCurrentCampaignSnapshots_Memoized()
   1140     insurgencyMapData = {}
   1141     nameData = {}
   1142     corruptionSuppressionValue = {}
   1143 
   1144     def hintFun(solarsystemid):
   1145         factionName = nameData[solarsystemid]
   1146         corruption, suppression = corruptionSuppressionValue[solarsystemid]
   1147         if corruption == 5:
   1148             maxStageLabel = GetByLabel('UI/PirateInsurgencies/maxCorruption')
   1149             return u'{}<br/>{}<br/>{}'.format(GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), factionName, maxStageLabel)
   1150         elif suppression == 5:
   1151             maxStageLabel = GetByLabel('UI/PirateInsurgencies/maxSuppression')
   1152             return u'{}<br/>{}<br/>{}'.format(GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), factionName, maxStageLabel)
   1153         else:
   1154             return u'{}<br/>{}'.format(GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), factionName)
   1155 
   1156     for snapshot in snapshots:
   1157         for solarsystemid in snapshot.coveredSolarsystemIDs:
   1158             insurgencyMapData[solarsystemid] = 1.0
   1159             nameData[solarsystemid] = get_faction_name(snapshot.pirateFactionID)
   1160             corruptionStage = corruptionSuppressionSvc.GetSystemCorruptionStage(solarsystemid)
   1161             suppressionStage = corruptionSuppressionSvc.GetSystemSuppressionStage(solarsystemid)
   1162             corruptionSuppressionValue[solarsystemid] = (corruptionStage, suppressionStage)
   1163             colorInfo.solarSystemDict[solarsystemid] = (5,
   1164              1,
   1165              (hintFun, (solarsystemid,)),
   1166              None)
   1167 
   1168     colorInfo.colorList = (mapcommon.NEUTRAL_COLOR, Color.HextoRGBA('#9EFF00'))
   1169     colorCurve = starmap.GetColorCurve(colorInfo.colorList)
   1170     startColor = starmap.GetColorCurveValue(colorCurve, 1.0)
   1171     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/PirateInsurgencies/systemNotAffectedByInsurgency'), mapcommon.NEUTRAL_COLOR, data=None))
   1172     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/PirateInsurgencies/systemAffectedByInsurgency'), startColor, data=None))
   1173 
   1174 
   1175 def ColorStarsByRoamingWeather(colorInfo, starColorMode):
   1176     ms = sm.GetService('map')
   1177     participatingSystems = ms.GetAllRoamingWeatherSystems()
   1178     for solarSystem in participatingSystems:
   1179         if solarSystem.locationID in colorInfo.solarSystemDict:
   1180             color = colorInfo.solarSystemDict[solarSystem.locationID][3]
   1181             if color == COLOR_RED:
   1182                 continue
   1183             if color == COLOR_ORANGE and solarSystem.sceneType != taleConst.scenesTypes.onionHeadquarters:
   1184                 continue
   1185         colorInfo.solarSystemDict[solarSystem.locationID] = GetColorAndHintRoamingWeatherSystems(solarSystem.sceneType)
   1186 
   1187     colorInfo.legend.add(LegendItem(0, 'UI/Map/StarModeHandler/roamingWeather', COLOR_RED, data=None))
   1188 
   1189 
   1190 def ColorStarsByIncursionsGM(colorInfo, starColorMode):
   1191     ms = session.ConnectToRemoteService('map')
   1192     participatingSystems = ms.GetSystemsInIncursions()
   1193     for solarSystem in participatingSystems:
   1194         colorInfo.solarSystemDict[solarSystem.locationID] = GetColorAndHintForIncursionSystemGm(solarSystem.sceneType, solarSystem.templateNameID)
   1195 
   1196     colorInfo.legend.add(LegendItem(0, GetByLabel('UI/Map/StarModeHandler/incursionStageing'), COLOR_GREEN, data=None))
   1197     colorInfo.legend.add(LegendItem(1, GetByLabel('UI/Map/StarModeHandler/incursionVanguard'), COLOR_PURPLE, data=None))
   1198     colorInfo.legend.add(LegendItem(2, GetByLabel('UI/Map/StarModeHandler/incursionAssault'), COLOR_ORANGE, data=None))
   1199     colorInfo.legend.add(LegendItem(3, GetByLabel('UI/Map/StarModeHandler/incursionHQ'), COLOR_RED, data=None))
   1200     colorInfo.legend.add(LegendItem(4, 'Incursion Staging', COLOR_WHITE, data=None))
   1201     colorInfo.legend.add(LegendItem(5, 'Incursion Spread', COLOR_GRAY, data=None))
   1202     colorInfo.legend.add(LegendItem(6, 'Incursion Final Encounter', COLOR_PURPLE, data=None))
   1203 
   1204 
   1205 def GetColorAndHintForIncursionSystem(sceneType, templateNameID):
   1206     distributionName = GetByMessageID(templateNameID)
   1207     if distributionName:
   1208         distributionName += '\n'
   1209     if sceneType == taleConst.scenesTypes.staging:
   1210         incursionHint = lambda : distributionName + GetByLabel('UI/Map/StarModeHandler/incursionStageing')
   1211         return (5,
   1212          0,
   1213          (incursionHint, ()),
   1214          COLOR_YELLOW)
   1215     if sceneType == taleConst.scenesTypes.vanguard:
   1216         incursionHint = lambda : distributionName + GetByLabel('UI/Map/StarModeHandler/incursionPraticipant')
   1217         return (2.5,
   1218          1,
   1219          (incursionHint, ()),
   1220          COLOR_ORANGE)
   1221     if sceneType == taleConst.scenesTypes.incursionStaging:
   1222         incursionHint = lambda : distributionName + GetByLabel('UI/Map/StarModeHandler/incursionStageing')
   1223         return (3.75,
   1224          2,
   1225          (incursionHint, ()),
   1226          COLOR_YELLOW)
   1227 
   1228 
   1229 def GetColorAndHintRoamingWeatherSystems(sceneType):
   1230     hint = lambda : GetByLabel('UI/Map/StarModeHandler/roamingWeather')
   1231     if sceneType == taleConst.scenesTypes.onionHeadquarters:
   1232         size = 5
   1233         color = COLOR_RED
   1234     elif sceneType == taleConst.scenesTypes.onionJump1:
   1235         size = 3.75
   1236         color = COLOR_ORANGE
   1237     else:
   1238         size = 2.0
   1239         color = COLOR_YELLOW
   1240     return (size,
   1241      0,
   1242      (hint, ()),
   1243      color)
   1244 
   1245 
   1246 def GetColorAndHintForIncursionSystemGm(sceneType, templateNameID):
   1247     distributionName = GetByMessageID(templateNameID)
   1248     if distributionName:
   1249         distributionName += '\n'
   1250     if sceneType == taleConst.scenesTypes.staging:
   1251         return (5,
   1252          0,
   1253          (lambda : distributionName + 'Staging', ()),
   1254          COLOR_GREEN)
   1255     if sceneType == taleConst.scenesTypes.vanguard:
   1256         return (2.5,
   1257          1,
   1258          (lambda : distributionName + 'Vanguard', ()),
   1259          COLOR_PURPLE)
   1260     if sceneType == taleConst.scenesTypes.assault:
   1261         return (2.5,
   1262          2,
   1263          (lambda : distributionName + 'Assault', ()),
   1264          COLOR_ORANGE)
   1265     if sceneType == taleConst.scenesTypes.headquarters:
   1266         return (2.5,
   1267          3,
   1268          (lambda : distributionName + 'HeadQuarters', ()),
   1269          COLOR_RED)
   1270     if sceneType in (taleConst.scenesTypes.incursionStaging, taleConst.scenesTypes.incursionLightInfestation):
   1271         return (3.75,
   1272          4,
   1273          (lambda : distributionName + 'Staging', ()),
   1274          COLOR_WHITE)
   1275     if sceneType in (taleConst.scenesTypes.incursionMediumInfestation, taleConst.scenesTypes.incursionHeavyInfestation):
   1276         return (2.5,
   1277          5,
   1278          (lambda : distributionName + 'Incursion Spread', ()),
   1279          COLOR_GRAY)
   1280     if sceneType == taleConst.scenesTypes.incursionFinalEncounter:
   1281         return (2.5,
   1282          6,
   1283          (lambda : distributionName + 'Incursion Final Encounter', ()),
   1284          COLOR_PURPLE)
   1285 
   1286 
   1287 def ColorStarsByJobs24Hours(colorInfo, starColorMode, activityID):
   1288     systemRows = sm.RemoteSvc('map').GetIndustryJobsOverLast24Hours(activityID)
   1289     if systemRows:
   1290         maxJobs = max((r.noOfJobs for r in systemRows))
   1291         intensityFunc = lambda value: 50 * value / maxJobs
   1292         colorScalarFunc = lambda value: value / maxJobs
   1293         hintFunc = lambda solarSystemID, value: (lambda : GetByLabel('UI/Map/StarModeHandler/jobsStartedLast24Hours', noOfJobs=value), ())
   1294         jobsBySystem = {row.solarSystemID:row.noOfJobs for row in systemRows}
   1295         colorInfo.solarSystemDict.update(_GetColorDict(jobsBySystem, intensityFunc, colorScalarFunc, hintFunc))
   1296         colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
   1297 
   1298 
   1299 def ColorStarsByIndustryCostModifier(colorInfo, starColorMode, activityID):
   1300     systemRows = sm.RemoteSvc('map').GetIndustryCostModifier(activityID)
   1301     minValue = min(systemRows.values())
   1302     maxValue = max(systemRows.values())
   1303     colorScalarFunc = lambda value: ((value - minValue) / (maxValue - minValue) if maxValue != minValue else 0)
   1304     intensityFunc = lambda value: colorScalarFunc(value) * 20
   1305     hintFunc = lambda solarSystemID, value: (lambda : GetByLabel('UI/Map/StarModeHandler/industryCostModifier', index=value * 100.0), ())
   1306     colorInfo.solarSystemDict.update(_GetColorDict(systemRows, intensityFunc, colorScalarFunc, hintFunc))
   1307     colorInfo.colorList = (trinity.TriColor(0.5, 0.32, 0.0), trinity.TriColor(0.7, 0.0, 0.01))
   1308 
   1309 
   1310 def _GetColorDict(valueBySolarSystem, intensityFunc, colorScalarFunc, hintFunc):
   1311     colorInfoBySolarSystemID = {}
   1312     for solarSystemID, value in valueBySolarSystem.iteritems():
   1313         colorInfoBySolarSystemID[solarSystemID] = (intensityFunc(value),
   1314          colorScalarFunc(value),
   1315          hintFunc(solarSystemID, value),
   1316          None)
   1317 
   1318     return colorInfoBySolarSystemID