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

warzoneMapPanel.py (29449B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\fwwarzone\client\dashboard\warzoneMapPanel.py
      2 import eveicon
      3 import uthread2
      4 from carbonui import TextColor, uiconst
      5 from carbonui.control.checkbox import Checkbox
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.fill import Fill
      8 from carbonui.primitives.sprite import Sprite
      9 from carbonui.primitives.transform import Transform
     10 from clientsettings.setting import CharSettingEnum, CharSettingBool
     11 from carbonui.uianimations import animations
     12 from carbonui.uicore import uicore
     13 from characterdata.factions import get_faction_name
     14 from eve.client.script.ui import eveColor
     15 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     16 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel
     17 from eveexceptions import ExceptionEater
     18 from fwwarzone.client.dashboard.collapsingSection import CollapsingSection
     19 from fwwarzone.client.dashboard.mapData import WarzoneMapData
     20 from fwwarzone.client.util import CachedGetBattlefieldInstances
     21 from localization import GetByLabel, GetByMessageID
     22 from pirateinsurgency.client.dashboard.const import WARZONE_ID_TO_PIRATE_FACTION_ID
     23 STAR_TEX_PATH = 'res:/UI/Texture/classes/frontlines/star.png'
     24 ZOOM_LEVELS = [1.0, 0.6]
     25 ZOOM_SETTING = CharSettingEnum(settings_key='warzone_map_panel_zoom_level', default_value=0, options=range(len(ZOOM_LEVELS)))
     26 
     27 def getColorUIHighlight(alpha = 1.0):
     28     elementColor = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT)
     29     return color.GetColor(elementColor, alpha=alpha)
     30 
     31 
     32 class WarzoneMapPanel(Container):
     33     GLOW_HIGHLIGHT_BRIGHTNESS = 1.5
     34     GLOW_STANDARD_BRIGHTNESS = 0.5
     35     default_minWidth = 640
     36     default_minHeight = 640
     37     default_viewSize = 1800
     38     default_bgColor = eveColor.BLACK
     39     default_warzoneId = 2
     40     ZOOM_LEVELS = ZOOM_LEVELS
     41     warzoneToFocusedSystem = {1: 30002959,
     42      2: 30003840}
     43 
     44     def ApplyAttributes(self, attributes):
     45         self.warZoneMap = None
     46         Container.ApplyAttributes(self, attributes)
     47         self.cameraX = 0
     48         self.cameraY = 0
     49         self.isZooming = False
     50         self.linkLinesBySystemId = {}
     51         self.warzoneId = attributes.get('warzoneId', self.default_warzoneId)
     52         self.centerOnSystemId = self.warzoneToFocusedSystem[self.warzoneId]
     53         self.viewSize = attributes.get('viewSize', self.default_viewSize)
     54         self.starSelectedCallback = attributes.get('starSelectedCallback', lambda *args: args)
     55         self.displayAsFactionID = attributes.get('displayAsFactionID')
     56         self.currentZoomLevelIndex = ZOOM_SETTING.get()
     57         self.interstellarShipCasterFactionFocusSignal = attributes.get('interstellarShipCasterFactionFocusSignal')
     58         self.interstellarShipCasterFactionFocusSignal.connect(self.OnInterstellarShipCasterFactionFocus)
     59         self.battlefields = None
     60         self.mapData = None
     61         self.legend = None
     62         self.showLegendSetting = attributes.get('showLegendSetting')
     63         self.showLegendSetting.on_change.connect(self.UpdateLegendShown)
     64         self.showSystemNamesSetting = CharSettingBool('FWWindowShowSystemNames', True)
     65         self.showStatusSpritesSetting = CharSettingBool('FWWindowShowStatusSprites', True)
     66         self.showIAmhHereIconSetting = CharSettingBool('FWWindowShowIAmHereIcon', True)
     67         self.showLandingPadsSetting = CharSettingBool('FWWindowShowLandingPadsIcon', True)
     68         self.showShipcasterSetting = CharSettingBool('FWWindowShowShipcaster', True)
     69         self.showBattlefieldSetting = CharSettingBool('FWWindowShowBattlefield', True)
     70         self.showFOBSetting = CharSettingBool('FWWindowShowFOBIcons', True)
     71         self.ResetVariables()
     72         self.AsyncLoadMap()
     73 
     74     def ResetVariables(self):
     75         self.myLocationCont = None
     76         self.battlefielMarkersBySolarSystemID = {}
     77         self.landingPadMarkersBySolarSystemID = {}
     78         self.shipcasterMarkersBySolarSystemID = {}
     79         self.FOBMarkersBySolarSystemID = {}
     80         self.allLinkLines = []
     81         self.systemNameLabels = []
     82         self.systemStateIcons = []
     83         self.statusSprites = []
     84         self.navigationSystemSovIcons = []
     85         self.starCoordBySystemID = {}
     86 
     87     def AsyncLoadMap(self):
     88         uthread2.StartTasklet(self._LoadMap)
     89 
     90     def _LoadMap(self):
     91         self.Flush()
     92         loadingWheel = LoadingWheel(width=64, height=64, parent=self, align=uiconst.CENTER)
     93         self.battlefields = CachedGetBattlefieldInstances()
     94         self.mapData = WarzoneMapData(sm.GetService('fwWarzoneSvc'))
     95         self.ResetVariables()
     96         self.Flush()
     97         self.ConstructMap()
     98         self.HideMapDetails(animate=False)
     99         self.ConstructBattlefieldMarkers()
    100         self.ConstructFOBMarkers()
    101         self.ConstructLandingPadMarkers(self.displayAsFactionID)
    102         self.ConstructShipCasterMarkers(self.displayAsFactionID)
    103         self.UpdateMarkedLocations()
    104         self.UpdateDetailsByZoomLevel(animate=False)
    105         self.ZoomTo(self.ZOOM_LEVELS[self.currentZoomLevelIndex], False)
    106         loadingWheel.Close()
    107 
    108     def UpdateLegendShown(self, active):
    109         if self.legend is None:
    110             return
    111         if active:
    112             animations.FadeIn(self.legend)
    113         else:
    114             animations.FadeOut(self.legend)
    115 
    116     def OnInterstellarShipCasterFactionFocus(self, factionID):
    117         if self.destroyed:
    118             return
    119         self.ConstructShipCasterMarkers(factionID)
    120         self.ConstructLandingPadMarkers(factionID)
    121         self.UpdateMarkedLocations()
    122         self.UpdateDetailsByZoomLevel()
    123 
    124     def OnMouseWheel(self, *args):
    125         modifier = uicore.mouseInputHandler.GetCameraZoomModifier()
    126         self.OnZoom(modifier * uicore.uilib.dz)
    127 
    128     def OnZoom(self, dz):
    129         if self.isZooming:
    130             return
    131         if dz < 0:
    132             self.currentZoomLevelIndex = max(0, self.currentZoomLevelIndex - 1)
    133         else:
    134             self.currentZoomLevelIndex = min(len(self.ZOOM_LEVELS) - 1, self.currentZoomLevelIndex + 1)
    135         self.UpdateDetailsByZoomLevel()
    136         ZOOM_SETTING.set(self.currentZoomLevelIndex)
    137         self.ZoomTo(self.ZOOM_LEVELS[self.currentZoomLevelIndex])
    138 
    139     def UpdateDetailsByZoomLevel(self, animate = True):
    140         if self.currentZoomLevelIndex == 0:
    141             self.ShowMapDetails(animate)
    142         elif self.currentZoomLevelIndex == 1:
    143             self.HideMapDetails(animate)
    144         zoomValue = self.ZOOM_LEVELS[self.currentZoomLevelIndex]
    145         if self.myLocationCont:
    146             self.myLocationCont.AdjustToZoom(zoomValue, animate)
    147         for battlefieldMarker in self.battlefielMarkersBySolarSystemID.itervalues():
    148             battlefieldMarker.AdjustToZoom(zoomValue, animate)
    149 
    150         for landingPadMarker in self.landingPadMarkersBySolarSystemID.itervalues():
    151             landingPadMarker.AdjustToZoom(zoomValue, animate)
    152 
    153         for shipcasterMarker in self.shipcasterMarkersBySolarSystemID.itervalues():
    154             shipcasterMarker.AdjustToZoom(zoomValue, animate)
    155 
    156         for FOBMarker in self.FOBMarkersBySolarSystemID.itervalues():
    157             FOBMarker.AdjustToZoom(zoomValue, animate)
    158 
    159     def ShowMapDetails(self, animate = True):
    160         elementToFadeIn = self.allLinkLines[:]
    161         elementToFadeIn += self.navigationSystemSovIcons
    162         if self.showStatusSpritesSetting.is_enabled():
    163             elementToFadeIn += self.statusSprites
    164         if self.showSystemNamesSetting.is_enabled():
    165             elementToFadeIn += self.systemNameLabels
    166         for element in elementToFadeIn:
    167             if animate:
    168                 animations.FadeIn(element)
    169             else:
    170                 element.opacity = 1.0
    171 
    172         if self.showStatusSpritesSetting.is_enabled():
    173             for starIcon in self.systemStateIcons:
    174                 if animate:
    175                     animations.FadeOut(starIcon)
    176                 else:
    177                     starIcon.opacity = 0.0
    178 
    179     def HideMapDetails(self, animate = True):
    180         elementToFadeOut = self.allLinkLines[:]
    181         elementToFadeOut += self.systemNameLabels
    182         elementToFadeOut += self.statusSprites
    183         elementToFadeOut += self.navigationSystemSovIcons
    184         for element in elementToFadeOut:
    185             if animate:
    186                 animations.FadeOut(element)
    187             else:
    188                 element.opacity = 0.0
    189 
    190         for starIcon in self.systemStateIcons:
    191             if animate:
    192                 animations.FadeIn(starIcon)
    193             else:
    194                 starIcon.opacity = 1.0
    195 
    196     def ToggleShowSystemNames(self):
    197         if self.currentZoomLevelIndex == 0:
    198             if self.showSystemNamesSetting.is_enabled():
    199                 for element in self.systemNameLabels:
    200                     animations.FadeOut(element)
    201 
    202             else:
    203                 for element in self.systemNameLabels:
    204                     animations.FadeIn(element)
    205 
    206         self.showSystemNamesSetting.toggle()
    207 
    208     def ToggleShowStatusSprites(self):
    209         if self.currentZoomLevelIndex == 0:
    210             if self.showStatusSpritesSetting.is_enabled():
    211                 for element in self.statusSprites:
    212                     animations.FadeOut(element)
    213 
    214                 for starIcon in self.systemStateIcons:
    215                     animations.FadeIn(starIcon)
    216 
    217             else:
    218                 for element in self.statusSprites:
    219                     animations.FadeIn(element)
    220 
    221                 for starIcon in self.systemStateIcons:
    222                     animations.FadeOut(starIcon)
    223 
    224         self.showStatusSpritesSetting.toggle()
    225 
    226     def ZoomTo(self, newScale, animate = True):
    227         self.isZooming = True
    228         self.warZoneMap.topLayer.state = uiconst.UI_DISABLED
    229 
    230         def _end_zoom():
    231             self.warZoneMap.topLayer.state = uiconst.UI_PICKCHILDREN
    232             self.isZooming = False
    233 
    234         if animate:
    235             uicore.animations.MorphScalar(self.warZoneMap, 'scale', self.warZoneMap.scale, newScale, duration=0.35, callback=_end_zoom)
    236         else:
    237             self.warZoneMap.scale = newScale
    238             _end_zoom()
    239 
    240     def ConstructMap(self):
    241         mapData = self.mapData.GetWarzoneSystems(self.warzoneId)
    242         systems = mapData.systems
    243         from fwwarzone.client.dashboard.warzoneMap import WarzoneMap
    244         self.warZoneMap = WarzoneMap(parent=self, viewSize=self.viewSize, selectStarFunction=self.SelectStarFunction, warzoneId=self.warzoneId, opacity=0.0)
    245         warZoneMapOutput = self.warZoneMap.LoadSystems(systems, mapData.mapWidth, mapData.mapHeight)
    246         self.starCoordBySystemID = warZoneMapOutput.stars
    247         self.systemNameLabels.extend(warZoneMapOutput.systemNameLabels.values())
    248         self.systemStateIcons.extend(warZoneMapOutput.systemStateIcons.values())
    249         self.statusSprites.extend(warZoneMapOutput.statusSprites.values())
    250         self.linkLinesBySystemId.update(warZoneMapOutput.linkLinesBySystemId)
    251         x = systems[self.centerOnSystemId].position[0] / float(mapData.mapWidth) * self.viewSize
    252         y = systems[self.centerOnSystemId].position[1] / float(mapData.mapHeight) * self.viewSize
    253         self._MoveCamera(x, y, animate=False)
    254         animations.FadeIn(self.warZoneMap, duration=2.0)
    255         self.ConstructLegend()
    256 
    257     def FadeMarkerIcons(self, iconsMap, fadeOut = True):
    258         if fadeOut:
    259             for markerCont in iconsMap.itervalues():
    260                 animations.FadeOut(markerCont)
    261 
    262         else:
    263             for markerCont in iconsMap.itervalues():
    264                 animations.FadeIn(markerCont)
    265 
    266     def ConstructLegend(self, *args):
    267         if self.legend:
    268             self.legend.Flush()
    269             self.legend.Close()
    270         legendCont = Container(name='legendCont', align=uiconst.TOTOP, height=208, clipChildren=True, state=uiconst.UI_PICKCHILDREN)
    271         Fill(bgParent=legendCont, color=eveColor.BLACK, opacity=0.75)
    272         toggleSystemNames = lambda _: self.ToggleShowSystemNames()
    273         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/systemNames'), texturePath=eveicon.solar_system, func=toggleSystemNames, active=self.showSystemNamesSetting.is_enabled())
    274         toggleStatusSprites = lambda _: self.ToggleShowStatusSprites()
    275         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/warzoneIconsLegendText'), texturePath=eveicon.theaters_of_war, func=toggleStatusSprites, active=self.showStatusSpritesSetting.is_enabled())
    276 
    277         def _showIAmHereIconAndChangeSetting(active):
    278             if active:
    279                 animations.FadeIn(self.myLocationCont)
    280             else:
    281                 animations.FadeOut(self.myLocationCont)
    282             self.showIAmhHereIconSetting.set(active)
    283 
    284         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/Map/StarMap/lblYouAreHere'), texturePath=eveicon.user, func=_showIAmHereIconAndChangeSetting, active=self.showIAmhHereIconSetting.is_enabled())
    285 
    286         def showMarkersAndChangeSetting(active, markersMap, setting):
    287             if active:
    288                 self.FadeMarkerIcons(markersMap, fadeOut=False)
    289             else:
    290                 self.FadeMarkerIcons(markersMap)
    291             setting.set(active)
    292 
    293         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/landingPadLegendText'), texturePath=eveicon.landing_pad, func=lambda active: showMarkersAndChangeSetting(active, self.landingPadMarkersBySolarSystemID, self.showLandingPadsSetting), active=self.showLandingPadsSetting.is_enabled())
    294         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/shipcasterLegendText'), texturePath=eveicon.interstellar_shipcaster, func=lambda active: showMarkersAndChangeSetting(active, self.shipcasterMarkersBySolarSystemID, self.showShipcasterSetting), active=self.showShipcasterSetting.is_enabled())
    295         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/battlefieldLegendText'), texturePath=eveicon.battlefield, func=lambda active: showMarkersAndChangeSetting(active, self.battlefielMarkersBySolarSystemID, self.showBattlefieldSetting), active=self.showBattlefieldSetting.is_enabled())
    296         LegendRow(parent=legendCont, align=uiconst.TOTOP, label=GetByLabel('UI/FactionWarfare/frontlinesDashboard/pirateFOBLegendText'), texturePath=eveicon.forward_operating_base_fob, func=lambda active: showMarkersAndChangeSetting(active, self.FOBMarkersBySolarSystemID, self.showFOBSetting), active=self.showFOBSetting.is_enabled())
    297         self.legend = CollapsingSection(parent=self, align=uiconst.TOPLEFT, width=200, headerText='Legend', section=legendCont, idx=0)
    298         Fill(bgParent=self.legend.headerCont, color=eveColor.BLACK, opacity=0.75)
    299         if not self.showLegendSetting.is_enabled():
    300             self.legend.opacity = 0.0
    301 
    302     def SelectStarFunction(self, systemId):
    303         return self.starSelectedCallback(systemId)
    304 
    305     def _MoveCamera(self, x, y, animate = True):
    306         self.warZoneMap.PanTo(x / self.viewSize, y / self.viewSize, duration=0.15, animate=animate)
    307 
    308     def GetOccupierColor(self, occupierId):
    309         if occupierId == 500003:
    310             return eveColor.HOT_RED
    311         else:
    312             return eveColor.SMOKE_BLUE
    313 
    314     def DebugReloadMap(self):
    315         fwWarzoneSvc = sm.GetService('fwWarzoneSvc')
    316         self.mapData = WarzoneMapData(fwWarzoneSvc)
    317         self.mapData.occupationStates = fwWarzoneSvc.GetAllOccupationStatesUncached()
    318         self._LoadMap()
    319 
    320     def ReloadMap(self):
    321         self._LoadMap()
    322 
    323     def UpdateMarkedLocations(self):
    324         self.UpdateCurrentLocation()
    325         self.UpdateBattlefieldLocation()
    326         self.UpdatelandingPadLocations()
    327         self.UpdateShipCasterLocations()
    328         self.UpdateFOBmarkerLocation()
    329         self.FadeMarkerIcons(self.battlefielMarkersBySolarSystemID, fadeOut=not self.showBattlefieldSetting.is_enabled())
    330         self.FadeMarkerIcons(self.landingPadMarkersBySolarSystemID, fadeOut=not self.showLandingPadsSetting.is_enabled())
    331         self.FadeMarkerIcons(self.shipcasterMarkersBySolarSystemID, fadeOut=not self.showShipcasterSetting.is_enabled())
    332         self.FadeMarkerIcons(self.FOBMarkersBySolarSystemID, fadeOut=not self.showFOBSetting.is_enabled())
    333         if self.showIAmhHereIconSetting.is_enabled():
    334             animations.FadeIn(self.myLocationCont)
    335         else:
    336             animations.FadeOut(self.myLocationCont)
    337 
    338     def UpdateCurrentLocation(self):
    339         if self.warZoneMap is None or self.warZoneMap.markerLayer is None or self.warZoneMap.markerLayer.destroyed:
    340             return
    341         if not self.myLocationCont or self.myLocationCont.destroyed:
    342             self.ConstructMyLocationCont()
    343         pos = self.starCoordBySystemID.get(session.solarsystemid2, None)
    344         if pos is None:
    345             self.myLocationCont.Hide()
    346             return
    347         self.myLocationCont.Show()
    348         x, y = pos
    349         self.myLocationCont.SetOffset(x, y, False)
    350 
    351     def ConstructMyLocationCont(self):
    352         self.myLocationCont = MapMarker(parent=self.warZoneMap.markerLayer, idx=0, currentZoomValue=self.ZOOM_LEVELS[self.currentZoomLevelIndex], text=GetByLabel('UI/Map/StarMap/lblYouAreHere'))
    353         if self.showIAmhHereIconSetting.is_enabled():
    354             self.myLocationCont.opacity = 0.0
    355 
    356     def ConstructShipCasterMarkers(self, factionID):
    357         for marker in self.shipcasterMarkersBySolarSystemID.itervalues():
    358             marker.Close()
    359 
    360         if self.warZoneMap is None:
    361             return
    362         self.shipcasterMarkersBySolarSystemID = {}
    363         hqSystemId = sm.GetService('fwWarzoneSvc').GetAllHQSystems()
    364         factionsWithShipcaster = sm.GetService('shipcaster').GetFactionsWithShipcaster()
    365         if factionID in factionsWithShipcaster:
    366             solarSystemID = hqSystemId[factionID]
    367             marker = ShipCasterMarker(parent=self.warZoneMap.battleFieldMarkerLayer, idx=0, currentZoomValue=self.ZOOM_LEVELS[self.currentZoomLevelIndex], text=GetByLabel('UI/FactionWarfare/frontlinesDashboard/shipcasterSectionHeader'))
    368             if not self.showShipcasterSetting.is_enabled():
    369                 marker.opacity = 0.0
    370             self.shipcasterMarkersBySolarSystemID[solarSystemID] = marker
    371 
    372     def ConstructFOBMarkers(self):
    373         snapshots = sm.GetService('insurgencyCampaignSvc').GetCurrentCampaignSnapshots_Memoized()
    374         for snapshot in snapshots:
    375             if snapshot.warzoneID == self.warzoneId:
    376                 pirateFaction = WARZONE_ID_TO_PIRATE_FACTION_ID[self.warzoneId]
    377                 factionName = get_faction_name(pirateFaction)
    378                 marker = FOBMarker(parent=self.warZoneMap.battleFieldMarkerLayer, idx=0, currentZoomValue=self.ZOOM_LEVELS[self.currentZoomLevelIndex], text=GetByLabel('UI/PirateInsurgencies/FOBSystem', factionName=factionName))
    379                 if not self.showFOBSetting.is_enabled():
    380                     marker.opacity = 0.0
    381                 self.FOBMarkersBySolarSystemID[snapshot.originSolarsystemID] = marker
    382 
    383     def ConstructLandingPadMarkers(self, factionID):
    384         for marker in self.landingPadMarkersBySolarSystemID.itervalues():
    385             marker.Close()
    386 
    387         self.landingPadMarkersBySolarSystemID = {}
    388         landingPads = sm.GetService('shipcaster').GetAllLandingPads()
    389         for pad in landingPads:
    390             if pad.factionID == factionID and pad.isLinked and pad.solarSystemID in self.starCoordBySystemID:
    391                 marker = LandingPadMapMarker(parent=self.warZoneMap.battleFieldMarkerLayer, idx=0, currentZoomValue=self.ZOOM_LEVELS[self.currentZoomLevelIndex], text=GetByLabel('UI/FactionWarfare/frontlinesDashboard/landingPad'), landingPad=pad)
    392                 if not self.showLandingPadsSetting.is_enabled():
    393                     marker.opacity = 0.0
    394                 self.landingPadMarkersBySolarSystemID[pad.solarSystemID] = marker
    395 
    396     def ConstructBattlefieldMarkers(self):
    397         self.warZoneMap.battleFieldMarkerLayer.Flush()
    398         self.battlefielMarkersBySolarSystemID.clear()
    399         for solarSystemID, battlefieldInstances in self.battlefields.iteritems():
    400             if solarSystemID not in self.starCoordBySystemID:
    401                 continue
    402             if len(battlefieldInstances) == 0:
    403                 continue
    404             dungeon = battlefieldInstances[0]
    405             battlefieldMarker = BattlefieldMapMarker(parent=self.warZoneMap.battleFieldMarkerLayer, idx=0, currentZoomValue=self.ZOOM_LEVELS[self.currentZoomLevelIndex], text=GetByLabel('UI/FactionWarfare/frontlines/BattlefieldWithName', battlefieldName=GetByMessageID(dungeon.dungeonNameID)))
    406             self.battlefielMarkersBySolarSystemID[solarSystemID] = battlefieldMarker
    407 
    408     def UpdatelandingPadLocations(self):
    409         for solarSystemID, marker in self.landingPadMarkersBySolarSystemID.iteritems():
    410             pos = self.starCoordBySystemID.get(solarSystemID, None)
    411             if pos is None:
    412                 continue
    413             marker.Show()
    414             x, y = pos
    415             marker.SetOffset(x, y, False)
    416 
    417     def UpdateShipCasterLocations(self):
    418         for solarSystemID, marker in self.shipcasterMarkersBySolarSystemID.iteritems():
    419             pos = self.starCoordBySystemID.get(solarSystemID, None)
    420             if pos is None:
    421                 continue
    422             marker.Show()
    423             x, y = pos
    424             marker.SetOffset(x, y, False)
    425 
    426     def UpdateBattlefieldLocation(self):
    427         for solarSystemID, markerCont in self.battlefielMarkersBySolarSystemID.iteritems():
    428             pos = self.starCoordBySystemID.get(solarSystemID, None)
    429             if pos is None:
    430                 continue
    431             markerCont.Show()
    432             x, y = pos
    433             markerCont.SetOffset(x, y, False)
    434 
    435     def UpdateFOBmarkerLocation(self):
    436         for solarSystemID, marker in self.FOBMarkersBySolarSystemID.iteritems():
    437             pos = self.starCoordBySystemID.get(solarSystemID, None)
    438             if pos is None:
    439                 continue
    440             marker.Show()
    441             x, y = pos
    442             marker.SetOffset(x, y, False)
    443 
    444     def Close(self):
    445         super(WarzoneMapPanel, self).Close()
    446         with ExceptionEater('Closing WarzoneMapPanel'):
    447             self.interstellarShipCasterFactionFocusSignal.disconnect(self.OnInterstellarShipCasterFactionFocus)
    448 
    449 
    450 class MapMarker(Container):
    451     default_name = 'FW_MapMarker'
    452     default_align = uiconst.TOPLEFT
    453     default_width = 60
    454     default_height = 60
    455     default_innerSpriteWidth = 60
    456     default_innerSpriteHeight = 60
    457     markerTexture = 'res:/UI/Texture/classes/frontlines/hereYou.png'
    458     leftAligned = True
    459     default_showHereMarker = True
    460 
    461     def ApplyAttributes(self, attributes):
    462         super(MapMarker, self).ApplyAttributes(attributes)
    463         self.systemPos = (0, 0)
    464         self.currentZoomValue = attributes.get('currentZoomValue', 1.0)
    465         self.showHereMarker = attributes.get('showHereMarker', self.default_showHereMarker)
    466         self.innerSpriteWidth = attributes.get('innerSpriteWidth', self.default_innerSpriteWidth)
    467         self.innerSpriteHeight = attributes.get('innerSpriteHeight', self.default_innerSpriteHeight)
    468         text = attributes.get('text', 1.0)
    469         self.offsetCont = Transform(name='offsetCont', parent=self, align=uiconst.CENTER, pos=self.GetOffset(), scalingCenter=(0.5, 0.5))
    470         self.flipCont = Transform(name='flipCont', parent=self.offsetCont, align=uiconst.CENTER, pos=(0, 0, 32, 32), scalingCenter=(0.5, 0.5))
    471         innerSpriteColor = self.GetInnerSpriteColor()
    472         iconSprite = Sprite(name='iconSprite', parent=self.flipCont, texturePath=self.markerTexture, pos=(0,
    473          0,
    474          self.innerSpriteWidth,
    475          self.innerSpriteHeight), state=uiconst.UI_NORMAL, align=uiconst.CENTER, color=innerSpriteColor)
    476         if self.showHereMarker:
    477             iconSprite.state = uiconst.UI_DISABLED
    478         color = self.GetColor()
    479         if self.showHereMarker:
    480             backgroundSprite = Sprite(name='backgroundSprite', parent=self.flipCont, texturePath='res:/UI/Texture/classes/frontlines/here1.png', pos=(0, 0, 60, 60), align=uiconst.CENTER, state=uiconst.UI_NORMAL, color=color, outputMode=uiconst.OUTPUT_COLOR_AND_GLOW)
    481             backgroundSprite.OnMouseEnter = self.OnMouseEnterIcon
    482             backgroundSprite.OnMouseExit = self.OnMouseExitIcon
    483         else:
    484             iconSprite.OnMouseEnter = self.OnMouseEnterIcon
    485             iconSprite.OnMouseExit = self.OnMouseExitIcon
    486         labelOffset = 16 if self.leftAligned else 24
    487         self.labelMedium = EveLabelMedium(parent=self.offsetCont, text=text, align=uiconst.CENTERLEFT, left=self.offsetCont.width / 2 + labelOffset)
    488         self.labelMedium.Hide()
    489         self.labelLarge = EveLabelMedium(parent=self.offsetCont, text=text, align=uiconst.CENTERLEFT, left=self.offsetCont.width / 2 + labelOffset)
    490         self.labelLarge.Hide()
    491         self.AdjustToZoom(self.currentZoomValue, animate=False)
    492 
    493     def GetOffset(self):
    494         return (0, 0, 32, 32)
    495 
    496     def OnMouseEnterIcon(self, *args):
    497         if self.currentZoomValue > 0.8:
    498             self.labelMedium.Show()
    499             self.labelLarge.Hide()
    500         else:
    501             self.labelMedium.Hide()
    502             self.labelLarge.Show()
    503 
    504     def OnMouseExitIcon(self, *args):
    505         self.labelMedium.Hide()
    506         self.labelLarge.Hide()
    507 
    508     def AdjustToZoom(self, zoomValue, animate = True):
    509         self.currentZoomValue = zoomValue
    510         self.labelMedium.Hide()
    511         self.labelLarge.Hide()
    512         scale = 1.0 / zoomValue
    513         self.flipCont.scale = (1, 1) if self.leftAligned else (-1, 1)
    514         newScale = (scale, scale)
    515         if animate:
    516             uicore.animations.MorphVector2(self.offsetCont, 'scale', self.offsetCont.scale, newScale, duration=0.5)
    517         else:
    518             self.offsetCont.scale = newScale
    519         self.SetOffset(*self.systemPos)
    520 
    521     def SetOffset(self, x, y, animate = True):
    522         self.systemPos = (x, y)
    523         newLeft = self._GetNewLeft(x)
    524         newTop = y - 8 * self.currentZoomValue
    525         if animate:
    526             uicore.animations.MorphScalar(self, 'left', self.left, newLeft, duration=0.5)
    527             uicore.animations.MorphScalar(self, 'top', self.top, newTop, duration=0.5)
    528         else:
    529             self.left = newLeft
    530             self.top = newTop
    531 
    532     def _GetNewLeft(self, x):
    533         if self.leftAligned:
    534             modifier = 1
    535             widthOffset = -self.width
    536         else:
    537             modifier = -1
    538             widthOffset = 0
    539         newLeft = x + widthOffset + modifier * 8 * self.currentZoomValue
    540         return newLeft
    541 
    542     def GetColor(self):
    543         return eveColor.CRYO_BLUE
    544 
    545     def GetInnerSpriteColor(self):
    546         return TextColor.NORMAL
    547 
    548 
    549 class LandingPadMapMarker(MapMarker):
    550     markerTexture = 'res:/UI/Texture/classes/frontlines/shipcaster/landingpad_32.png'
    551     leftAligned = False
    552     default_showHereMarker = False
    553     default_innerSpriteHeight = 40
    554     default_innerSpriteWidth = 40
    555 
    556     def ApplyAttributes(self, attributes):
    557         self.landingPad = attributes.get('landingPad')
    558         super(LandingPadMapMarker, self).ApplyAttributes(attributes)
    559 
    560     def GetOffset(self):
    561         return (-22, -50, 32, 32)
    562 
    563 
    564 class ShipCasterMarker(MapMarker):
    565     markerTexture = 'res:/UI/Texture/classes/frontlines/shipcaster/shipcaster_icon_40.png'
    566     leftAligned = False
    567     default_showHereMarker = False
    568     default_innerSpriteHeight = 32
    569     default_innerSpriteWidth = 32
    570 
    571 
    572 class FOBMarker(MapMarker):
    573     default_name = 'FOBMapMarker'
    574     markerTexture = 'res:/UI/Texture/classes/frontlines/fob_32.png'
    575     leftAligned = False
    576     default_showHereMarker = False
    577     default_innerSpriteHeight = 32
    578     default_innerSpriteWidth = 32
    579 
    580     def GetColor(self):
    581         return eveColor.WHITE
    582 
    583 
    584 class BattlefieldMapMarker(MapMarker):
    585     markerTexture = 'res:/UI/Texture/classes/frontlines/battlefieldSmall.png'
    586     leftAligned = False
    587     default_showHereMarker = False
    588     default_innerSpriteHeight = 110
    589     default_innerSpriteWidth = 110
    590 
    591     def GetColor(self):
    592         return eveColor.WHITE
    593 
    594 
    595 class LegendRow(Container):
    596     default_height = 30
    597     default_state = uiconst.UI_NORMAL
    598 
    599     def ApplyAttributes(self, attributes):
    600         super(LegendRow, self).ApplyAttributes(attributes)
    601         self.label = attributes.get('label')
    602         self.texturePath = attributes.get('texturePath')
    603         self.clickCallback = attributes.get('func', self.defaultClickCallback)
    604         self.active = attributes.get('active', True)
    605         self.ConstructLayout()
    606 
    607     def OnClick(self, *args):
    608         if self.active:
    609             self.active = False
    610         else:
    611             self.active = True
    612         self.cb.SetChecked(self.active, False)
    613         self.clickCallback(self.active)
    614 
    615     def defaultClickCallback(self, active):
    616         pass
    617 
    618     def ConstructLayout(self):
    619         self.cb = Checkbox(parent=self, align=uiconst.CENTERLEFT, left=4, text=self.label, callback=self.OnClick)
    620         Sprite(parent=self, texturePath=self.texturePath, align=uiconst.CENTERLEFT, color=TextColor.NORMAL, pos=(24, 0, 16, 16))
    621         self.cb.label.left = 44
    622         self.UpdateCbState()
    623 
    624     def UpdateCbState(self):
    625         if self.active:
    626             self.cb.SetChecked(True, False)
    627         else:
    628             self.cb.SetChecked(False, False)
    629 
    630     def OnMouseEnter(self, *args):
    631         self.cb.OnMouseEnter()
    632 
    633     def OnMouseExit(self, *args):
    634         self.cb.OnMouseExit()