infoPanelLocationInfo.py (30623B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\infoPanels\infoPanelLocationInfo.py 2 import eveicon 3 import log 4 import telemetry 5 import carbonui.const as uiconst 6 import carbonui.fontconst 7 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst 8 import eveformat.client 9 import evelink.client 10 import localization 11 import threadutils 12 import trinity 13 from carbon.common.script.util import timerstuff 14 from carbon.common.script.util.commonutils import StripTags 15 from carbon.common.script.util.format import FmtAmt 16 from carbonui import PickState, TextColor 17 from carbonui.primitives.container import Container 18 from carbonui.primitives.containerAutoSize import ContainerAutoSize 19 from carbonui.primitives.layoutGrid import LayoutGrid 20 from carbonui.primitives.sprite import Sprite 21 from carbonui.util.color import Color 22 from entosis.occupancyCalculator import GetOccupancyMultiplier 23 from eve.client.script.ui.control import eveLabel 24 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelSmall, EveLabelLarge 25 from eve.client.script.ui.inflight.tidiIndicator import TiDiIndicator 26 from eve.client.script.ui.shared.infoPanels.InfoPanelBase import InfoPanelBase, ExpandButton 27 from eve.client.script.ui.shared.infoPanels.const import infoPanelConst 28 from eve.client.script.ui.shared.infoPanels.const import infoPanelUIConst 29 from eve.client.script.ui.shared.infoPanels.const.infoPanelConst import PANEL_LOCATION_INFO 30 from eve.client.script.ui.shared.infoPanels.listSurroundingsBtn import ListSurroundingsBtn 31 from eve.client.script.ui.shared.infoPanels.locationInfoConst import SYSTEM_INFO_SHOW_NEAREST_SETTING, SYSTEM_INFO_SHOW_SOVEREIGNTY 32 from eve.client.script.ui.shared.mapView.links.utils import get_map_link 33 from eve.client.script.ui.shared.maps.mapcommon import STARMODE_SECURITY 34 from eve.client.script.ui.shared.pointerTool.pointerToolConst import UNIQUE_NAME_LOCATION_INFO_PANEL 35 from eve.common.lib import appConst 36 from eve.common.script.sys import idCheckers 37 from eve.common.script.sys.idCheckers import IsAbyssalSpaceSystem, IsHiddenSpaceSystem 38 from eve.common.script.sys.idCheckers import IsKnownSpaceSystem 39 from eve.common.script.sys.idCheckers import IsVoidSpaceSystem 40 from eve.common.script.sys.idCheckers import IsWormholeSystem 41 from eveservices.menu import GetMenuService 42 from factionwarfare.client.text import GetLocalVictoryPointStateText 43 from pirateinsurgency.client.dashboard.const import CORRUPTION_STAGES 44 from security.client.const import get_range_id_by_security_status, get_range_icon_by_security_status, get_security_range_tagline, get_security_range_description 45 from security.client.securityColor import get_security_status_color 46 from solarsysteminterference.client.ui.interference_indicator import InterferenceIndicator 47 from solarsysteminterference.util import SystemCanHaveInterference 48 from sovDashboard import ShouldUpdateStructureInfo, GetSovStructureInfoByTypeID 49 from sovDashboard.cynoJammerIcon import CynoJammerIcon 50 from sovDashboard.dashboardSovHolderIcon import SovHolderIcon 51 from sovDashboard.defenseMultiplierIcon import DefenseMultiplierIcon 52 from stackless_response_router.exceptions import TimeoutException 53 from stargate.client import get_gate_lock_messenger 54 from stargate.client.gateLockController import GateLockController 55 from uihider import UiHiderMixin 56 from uthread2 import call_after_simtime_delay, StartTasklet 57 from utillib import KeyVal 58 59 class InfoPanelLocationInfo(UiHiderMixin, InfoPanelBase): 60 default_name = 'InfoPanelLocationInfo' 61 uniqueUiName = UNIQUE_NAME_LOCATION_INFO_PANEL 62 panelTypeID = PANEL_LOCATION_INFO 63 label = 'UI/Neocom/SystemInfo' 64 default_iconTexturePath = 'res:/UI/Texture/Classes/InfoPanels/LocationInfo.png' 65 __notifyevents__ = InfoPanelBase.__notifyevents__[:] 66 __notifyevents__.extend(['OnSolarsystemSovStructureChanged', 67 'OnCapitalSystemChanged', 68 'OnCynoJammerChanged', 69 'OnCurrentSystemSecurityChanged', 70 'OnDynamicBountyUpdate_Local', 71 'OnWarzoneOccupationStateUpdated_Local', 72 'OnCorruptionValueChanged_local', 73 'OnSuppressionValueChanged_local', 74 'OnEmanationLockUpdated']) 75 76 def ApplyAttributes(self, attributes): 77 super(InfoPanelLocationInfo, self).ApplyAttributes(attributes) 78 self.fwWarzoneSvc = sm.GetService('fwWarzoneSvc') 79 self.fwVictoryPointSvc = sm.GetService('fwVictoryPointSvc') 80 self.sovSvc = sm.GetService('sov') 81 self.infoPanelService = sm.GetService('infoPanel') 82 self.dynamicResourceSvc = sm.GetService('dynamicResourceSvc') 83 self.systemInterferenceSvc = sm.GetService('solarsystemInterferenceSvc') 84 self.corruptionSuppressionSvc = sm.GetService('corruptionSuppressionSvc') 85 self.validNearBy = [appConst.groupAsteroidBelt, 86 appConst.groupMoon, 87 appConst.groupPlanet, 88 appConst.groupStargate] 89 self.nearby = None 90 self.locationTimer = None 91 self.lastLocationID = None 92 self.sovHolderIcons = [] 93 self.bonusIcon = None 94 self.cynoJammerIcon = None 95 self.headerLabelCont = ContainerAutoSize(name='headerLabelCont', parent=self.headerCont, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT, height=23) 96 self.headerTopRow = Container(name='firstRow', parent=self.headerLabelCont, align=uiconst.TOPLEFT, pos=(0, 97 0, 98 self.GetHeaderTextMaxWidth(), 99 23)) 100 self.headerSecondRow = Container(name='secondRow', parent=self.headerLabelCont, align=uiconst.TOPLEFT, pos=(0, 101 23, 102 self.GetHeaderTextMaxWidth(), 103 23)) 104 self.tidiIndicator = TiDiIndicator(parent=self.headerTopRow, name='tidiIndicator', align=uiconst.TORIGHT, pos=(0, 0, 24, 24)) 105 systemLabelCont = ContainerAutoSize(name='systemLabelCont', parent=self.headerTopRow, align=uiconst.TOLEFT) 106 self.headerLabelSystemName = self.headerCls(name='headerLabelSystemName', parent=systemLabelCont, align=uiconst.TOLEFT, uniqueUiName=pConst.UNIQUE_NAME_SYSTEM_NAME_BTN) 107 self.sec_status_cont = ContainerAutoSize(name='sec_status_cont', parent=systemLabelCont, align=uiconst.TOLEFT, state=uiconst.UI_NORMAL) 108 self.headerLabelSecStatus = self.headerCls(name='headerLabelSecStatus', state=uiconst.UI_DISABLED, parent=self.sec_status_cont, align=uiconst.TOLEFT, padLeft=6, uniqueUiName=pConst.UNIQUE_NAME_SYSTEM_SECURITY_BTN) 109 icon_cont = Container(name='secStatusIconCont', parent=self.sec_status_cont, align=uiconst.TOLEFT, width=16, padLeft=4) 110 self.headerLabelSecStatusIcon = Sprite(name='headerLabelSecStatusIcon', parent=icon_cont, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT, width=16, height=16, texturePath=eveicon.high_sec) 111 self.sec_status_cont.LoadTooltipPanel = self._security_status_tooltip_panel 112 self.sec_status_cont.GetTooltipPointer = self._security_status_tooltip_pointer 113 self.headerConstellationTrace = self.headerCls(name='headerConstellationTrace', parent=self.headerSecondRow, align=uiconst.TOLEFT, padLeft=2) 114 self.headerRegionTrace = self.headerCls(name='headerRegionTrace', parent=self.headerSecondRow, align=uiconst.TOLEFT, padLeft=2) 115 self.nearestLocationInfo = eveLabel.EveLabelMedium(name='nearestLocationInfo', parent=self.mainCont, align=uiconst.TOTOP) 116 self.dynamicResourceInfoContainer = Container(parent=self.mainCont, align=uiconst.TOTOP, height=20, padTop=2) 117 self.sovInfoContainer = Container(parent=self.mainCont, align=uiconst.TOTOP, height=42, padTop=2) 118 self.emanationLockInfoContainer = Container(name='emanationLockInfoContainer', parent=self.mainCont, align=uiconst.TOTOP, height=22, padTop=2) 119 120 def GetHeaderTextMaxWidth(self): 121 return infoPanelUIConst.PANELWIDTH - infoPanelUIConst.LEFTPAD 122 123 @staticmethod 124 def IsAvailable(): 125 return True 126 127 def ConstructLayout(self): 128 self.topCont = ContainerAutoSize(name='topCont', parent=self, align=uiconst.TOTOP, height=28, alignMode=uiconst.TOTOP) 129 self.headerBtnCont = Container(name='headerBtnCont', parent=self.topCont, align=uiconst.TOPLEFT, width=infoPanelUIConst.LEFTPAD, height=infoPanelUIConst.BUTTON_SIZE) 130 self.headerCont = ContainerAutoSize(name='headerCont', parent=self.topCont, align=uiconst.TOTOP, padLeft=infoPanelUIConst.LEFTPAD) 131 self.headerCompactCont = Container(name='headerCompactCont', parent=self.topCont, opacity=0.0) 132 if not self.isModeFixed: 133 self.expandButton = ExpandButton(parent=self.headerBtnCont, align=uiconst.TOLEFT, width=infoPanelUIConst.BUTTON_SIZE, expanded=self.mode == infoPanelConst.MODE_NORMAL, on_click=self.ToggleMode) 134 else: 135 Container(name='expandButtonPlaceholder', parent=self.headerBtnCont, align=uiconst.TOLEFT, width=infoPanelUIConst.BUTTON_SIZE) 136 self.headerButton = self.ConstructHeaderButton() 137 self.mainCont = ContainerAutoSize(name='mainCont', parent=self, align=uiconst.TOTOP, padLeft=infoPanelUIConst.LEFTPAD, padTop=self.MAINPADTOP, padBottom=self.MAINPADBOTTOM if self.mode == infoPanelConst.MODE_NORMAL else 0) 138 139 def ConstructHeaderButton(self): 140 btn = ListSurroundingsBtn(parent=self.headerBtnCont, align=uiconst.TOLEFT, pos=(0, 141 0, 142 infoPanelUIConst.BUTTON_SIZE, 143 infoPanelUIConst.BUTTON_SIZE), texturePath=self.default_iconTexturePath, iconSize=16, showIcon=True, useDynamicMapItems=True, uniqueUiName=pConst.UNIQUE_NAME_LOCATION_ITEMS) 144 btn.hint = localization.GetByLabel('UI/Neocom/ListItemsInSystem') 145 btn.sr.owner = self 146 btn.sr.groupByType = 1 147 btn.filterCurrent = 1 148 btn.SetSolarsystemID(session.solarsystemid2) 149 return btn 150 151 def ConstructNormal(self): 152 self.UpdateLocationInfo() 153 154 def ConstructCompact(self): 155 self.UpdateMainLocationInfo() 156 157 @telemetry.ZONE_METHOD 158 def UpdateLocationInfo(self): 159 if session.solarsystemid2 and session.charid: 160 self.UpdateMainLocationInfo() 161 self.UpdateNearestOrStationLocationInfo() 162 self.UpdateDynamicResourceInfo() 163 self.UpdateSOVLocationInfo() 164 self.UpdateEmanationLockInfo() 165 166 @telemetry.ZONE_METHOD 167 def UpdateMainLocationInfo(self): 168 if session.solarsystemid2: 169 if IsAbyssalSpaceSystem(session.solarsystemid2): 170 abyssSvc = sm.GetService('abyss') 171 text = abyssSvc.get_mangled_system_name(session.solarsystemid2, session.charid) 172 self.headerLabelSystemName.fontPath = carbonui.fontconst.TRIGLAVIAN 173 self.headerLabelSystemName.state = uiconst.UI_DISABLED 174 self.headerLabelSystemName.text = text 175 elif IsVoidSpaceSystem(session.solarsystemid2) or IsHiddenSpaceSystem(session.solarsystemid2): 176 self.headerLabelSystemName.fontPath = None 177 self.headerLabelSystemName.state = uiconst.UI_NORMAL 178 self.headerLabelSystemName.text = localization.GetByLabel('UI/Common/Unknown') 179 else: 180 systemNameText = evelink.location_link(session.solarsystemid2, hint=StripTags(localization.GetByLabel('UI/Neocom/Autopilot/CurrentLocationType', itemType=appConst.typeSolarSystem))) 181 try: 182 corruptionStage = self.corruptionSuppressionSvc.GetCurrentSystemCorruption_Cached() 183 lawless = corruptionStage == CORRUPTION_STAGES 184 except TimeoutException: 185 lawless = False 186 187 secStatusHintText = localization.GetByLabel('UI/Map/StarMap/SecurityStatus') 188 if lawless: 189 secStatusHintText = localization.GetByLabel('UI/PirateInsurgencies/lawlessSecurityWarning') 190 secStatusText = eveformat.hint(hint=secStatusHintText, text=eveformat.solar_system_security_status(session.solarsystemid2, lawless=lawless)) 191 systemConstellationTraceText = self.infoPanelService.GetSolarSystemConstellationTraceDisplayString(session.solarsystemid2) 192 systemRegionTraceText = self.infoPanelService.GetSolarSystemRegionTraceDisplayString(session.solarsystemid2) 193 self.headerLabelSystemName.fontPath = None 194 self.headerLabelSystemName.state = uiconst.UI_NORMAL 195 self.headerLabelSecStatus.fontPath = None 196 self.sec_status_cont.state = uiconst.UI_NORMAL 197 self.headerConstellationTrace.fontPath = None 198 self.headerRegionTrace.fontPath = None 199 self.headerConstellationTrace.state = uiconst.UI_NORMAL 200 self.headerRegionTrace.state = uiconst.UI_NORMAL 201 self.headerLabelSystemName.text = systemNameText 202 self.headerLabelSecStatus.text = secStatusText 203 sec_status = sm.GetService('securitySvc').get_modified_security_level(session.solarsystemid2) 204 icon = get_range_icon_by_security_status(session.solarsystemid2, sec_status) 205 self.headerLabelSecStatusIcon.SetTexturePath(icon) 206 if SystemCanHaveInterference(session.solarsystemid2): 207 self.headerLabelSystemName.LoadTooltipPanel = self._interference_tooltip_panel 208 self.headerConstellationTrace.text = systemConstellationTraceText 209 self.headerConstellationTrace.top = 5 210 self.headerRegionTrace.text = systemRegionTraceText 211 self.headerRegionTrace.top = 5 212 max_width = self.GetHeaderTextMaxWidth() - self.tidiIndicator.width - 4 213 base_text_width = self.headerLabelSystemName.textwidth + self.headerLabelSecStatus.textwidth + self.headerLabelSecStatus.textwidth 214 constellation_text_width = self.headerConstellationTrace.textwidth + 4 if self.headerConstellationTrace.text else 0 215 region_text_width = self.headerRegionTrace.textwidth + 4 if self.headerRegionTrace.text else 0 216 remainder = max_width - base_text_width 217 if constellation_text_width < remainder: 218 remainder -= constellation_text_width 219 self.headerConstellationTrace.SetParent(self.headerTopRow) 220 if region_text_width > remainder: 221 self.headerSecondRow.display = True 222 self.headerRegionTrace.SetParent(self.headerSecondRow) 223 else: 224 self.headerRegionTrace.SetParent(self.headerTopRow) 225 self.headerSecondRow.display = False 226 else: 227 self.headerSecondRow.display = True 228 self.headerConstellationTrace.SetParent(self.headerSecondRow) 229 self.headerRegionTrace.SetParent(self.headerSecondRow) 230 self.headerButton.SetSolarsystemID(session.solarsystemid2) 231 232 def _security_status_tooltip_panel(self, panel, *args): 233 panel.state = uiconst.UI_NORMAL 234 grid = LayoutGrid(columns=2, rows=2, state=uiconst.UI_NORMAL) 235 grid.SetFixedGridWidth(320) 236 security_status = sm.GetService('map').GetSystemSecurityValue(session.solarsystemid2) 237 tagline = get_security_range_tagline(session.solarsystemid2, security_status) 238 grid.AddCell(EveLabelMedium(text=localization.GetByLabel(tagline) if tagline else '', color=TextColor.HIGHLIGHT, bold=True), cellPadding=(16, 16, 16, 0), colSpan=2) 239 description = get_security_range_description(session.solarsystemid2, security_status) 240 grid.AddCell(EveLabelMedium(text=localization.GetByLabel(description, color=Color.RGBtoHex(*get_security_status_color(security_status))) if description else '', maxWidth=352), cellPadding=16, colSpan=2) 241 grid.AddCell(EveLabelMedium(pickState=PickState.ON, text=localization.GetByLabel('UI/SecurityStatus/ShowOnMap', link=get_map_link(localization.GetByLabel('UI/SecurityStatus/LinkText'), None, STARMODE_SECURITY, get_range_id_by_security_status(session.solarsystemid2, security_status)))), cellPadding=(16, 0, 16, 16), colSpan=1) 242 panel.AddCell(grid, columns=panel.columns, cellPadding=(5, 5, 5, 5)) 243 244 def _security_status_tooltip_pointer(self): 245 return uiconst.POINT_TOP_1 246 247 def _interference_tooltip_panel(self, panel, *args): 248 grid = LayoutGrid(columns=2, rows=2, state=uiconst.UI_NORMAL) 249 grid.AddCell(EveLabelLarge(text=localization.GetByLabel('UI/Neocom/Autopilot/CurrentLocationType', itemType=appConst.typeSolarSystem), bold=True), colSpan=2) 250 interferenceCont = ContainerAutoSize(align=uiconst.TOLEFT) 251 (InterferenceIndicator(parent=interferenceCont, name='tooltipInterferenceIndicator', state=uiconst.UI_NORMAL, align=uiconst.TOLEFT, systemInterferenceSvc=self.systemInterferenceSvc, top=-2, left=4),) 252 (EveLabelLarge(parent=interferenceCont, text=localization.GetByLabel('UI/Common/Percentage', percentage=FmtAmt(self.systemInterferenceSvc.GetLocalInterferenceStateNow().normalisedInterferenceLevel * 100, showFraction=0)), align=uiconst.TOLEFT, padLeft=6),) 253 grid.AddCell(EveLabelLarge(text=localization.GetByLabel('UI/Neocom/interference')), cellPadding=(0, 5, 0, 0), colSpan=1) 254 grid.AddCell(interferenceCont, cellPadding=(0, 5, 0, 0), colSpan=1) 255 panel.AddCell(grid, columns=panel.columns, cellPadding=(5, 5, 5, 5)) 256 257 @telemetry.ZONE_METHOD 258 def UpdateNearestOrStationLocationInfo(self, nearestBall = None): 259 if IsAbyssalSpaceSystem(session.solarsystemid2) or IsVoidSpaceSystem(session.solarsystemid2) or IsHiddenSpaceSystem(session.solarsystemid2): 260 self.nearestLocationInfo.state = uiconst.UI_HIDDEN 261 return 262 nearestOrStationLabel = '' 263 if SYSTEM_INFO_SHOW_NEAREST_SETTING.is_enabled() and session.solarsystemid2: 264 if session.stationid or session.structureid: 265 try: 266 if session.stationid: 267 itemID = session.stationid 268 typeID = sm.GetService('station').stationItem.stationTypeID 269 else: 270 itemID = session.structureid 271 typeID = sm.GetService('structureDirectory').GetStructureInfo(itemID).typeID 272 stationName = cfg.evelocations.Get(itemID).name 273 nearestOrStationLabel = "<url=showinfo:%d//%d alt='%s'>%s</url>" % (typeID, 274 itemID, 275 localization.GetByLabel('UI/Generic/CurrentStation'), 276 stationName) 277 except AttributeError as e: 278 log.LogException('Failed when getting station/structure name') 279 280 else: 281 nearestBall = nearestBall or self.GetNearestBall() 282 if nearestBall: 283 self.nearby = nearestBall.id 284 slimItem = sm.StartService('michelle').GetItem(nearestBall.id) 285 if slimItem: 286 nearestOrStationLabel = "<url=showinfo:%d//%d alt='%s'>%s</url>" % (slimItem.typeID, 287 slimItem.itemID, 288 localization.GetByLabel('UI/Neocom/Nearest'), 289 cfg.evelocations.Get(nearestBall.id).locationName) 290 if self.locationTimer is None: 291 self.locationTimer = timerstuff.AutoTimer(1313, self.CheckNearest) 292 if nearestOrStationLabel: 293 self.nearestLocationInfo.text = nearestOrStationLabel 294 self.nearestLocationInfo.state = uiconst.UI_NORMAL 295 else: 296 self.nearestLocationInfo.state = uiconst.UI_HIDDEN 297 298 def FlushSovInfoContainer(self): 299 self.sovInfoContainer.Flush() 300 self.sovHolderIcons = [] 301 302 def _UpdateDynamicResourceInfoAsync(self): 303 dynamicBountyOutput, dbsIsActive = self.dynamicResourceSvc.GetDynamicBountySettingForCurrentSystem() 304 if dbsIsActive: 305 percentageOutput = dynamicBountyOutput * 100 306 self.dynamicResourceInfoContainer.display = True 307 bounties = EveLabelSmall(parent=self.dynamicResourceInfoContainer, text=localization.GetByLabel('UI/Neocom/SystemBountyOutputLabel', output=percentageOutput), align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 308 bounties.hint = localization.GetByLabel('UI/Neocom/SystemBountyOutputHint', output=percentageOutput) 309 310 def UpdateDynamicResourceInfo(self): 311 self.dynamicResourceInfoContainer.Flush() 312 self.dynamicResourceInfoContainer.display = False 313 StartTasklet(self._UpdateDynamicResourceInfoAsync) 314 315 @telemetry.ZONE_METHOD 316 def UpdateSOVLocationInfo(self): 317 self.FlushSovInfoContainer() 318 isKnownSpace = IsKnownSpaceSystem(session.solarsystemid2) 319 isWormhole = IsWormholeSystem(session.solarsystemid2) 320 if SYSTEM_INFO_SHOW_SOVEREIGNTY.is_enabled() and session.solarsystemid2 and (isKnownSpace or isWormhole): 321 self.sovInfoContainer.display = True 322 fwOccupationState = self.fwWarzoneSvc.GetLocalOccupationState() 323 factionID = self._GetSolarsystemFactionID(session.solarsystemid2, fwOccupationState) 324 if factionID: 325 self.DrawUnclaimableSystemInfo(factionID, fwOccupationState is not None) 326 elif isWormhole: 327 self.DrawWormholeInfo() 328 else: 329 solarsystemStructureInfo = self.sovSvc.GetSovStructuresInfoForSolarSystem(session.solarsystemid2) 330 self.DrawClaimableSystemInfo(solarsystemStructureInfo) 331 else: 332 self.sovInfoContainer.display = False 333 334 def _GetSolarsystemFactionID(self, solarsystemID, fwOccupationState): 335 if fwOccupationState is not None: 336 return fwOccupationState.occupierID 337 solarSystem = cfg.mapSystemCache.get(solarsystemID, None) 338 if solarSystem: 339 return getattr(solarSystem, 'factionID', None) 340 341 def GetAllianceIDFromCorpID(self, corpID): 342 if corpID: 343 return sm.GetService('corp').GetCorporation(corpID).allianceID 344 345 def ShowMultiplyBonusesIcon(self, parent, isCapital, left, capitalOwnerID): 346 devIndexInfo = self.sovSvc.GetIndexInfoForSolarsystem(session.solarsystemid2) 347 multiplier = 1 / GetOccupancyMultiplier(devIndexInfo.industrialIndexLevel, devIndexInfo.militaryIndexLevel, devIndexInfo.strategicIndexLevel, isCapital) 348 devIndexLevelInfo = (devIndexInfo.militaryIndexLevel, devIndexInfo.industrialIndexLevel, devIndexInfo.strategicIndexLevel) 349 if self.bonusIcon and not self.bonusIcon.destroyed: 350 self.bonusIcon.SetStatusFromMultiplier(multiplier, devIndexLevelInfo) 351 self.bonusIcon.ChangeCapitalState(isCapital=isCapital) 352 else: 353 self.bonusIcon = DefenseMultiplierIcon(parent=parent, iconSize=32, align=uiconst.CENTERLEFT, pos=(left, 354 0, 355 60, 356 60), currentMultiplier=multiplier, devIndexes=devIndexLevelInfo, isCapital=isCapital, capitalOwnerID=capitalOwnerID) 357 358 def DrawWormholeInfo(self): 359 self.sovInfoContainer.height = 10 360 EveLabelMedium(parent=self.sovInfoContainer, text=localization.GetByLabel('UI/Neocom/Unclaimable'), align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 361 362 def DrawUnclaimableSystemInfo(self, factionID, isFacWar): 363 sovIcon = SovHolderIcon(parent=self.sovInfoContainer, align=uiconst.CENTERLEFT, structureInfo=KeyVal(typeID=appConst.typeInfrastructureHub, solarSystemID=session.solarsystemid2, ownerID=factionID)) 364 factionText = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=cfg.eveowners.Get(factionID).name, info=('showinfo', appConst.typeFaction, factionID)) 365 if isFacWar: 366 victoryPointState = self.fwVictoryPointSvc.GetLocalVictoryPointState() 367 victoryPointStateText = GetLocalVictoryPointStateText(victoryPointState) 368 factionText = '%s %s' % (factionText, victoryPointStateText) 369 EveLabelMedium(parent=self.sovInfoContainer, text=factionText, left=sovIcon.width + 4, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 370 if sm.GetService('incursion').GetActiveIncursionData(): 371 self.cynoJammerIcon = CynoJammerIcon(parent=self.sovInfoContainer, iconSize=28, align=uiconst.CENTERRIGHT, pos=(0, 0, 32, 32), useBackground=False) 372 373 def DrawClaimableSystemInfo(self, solarsystemStructureInfo): 374 structureInfosByTypeID = GetSovStructureInfoByTypeID(solarsystemStructureInfo) 375 376 def GetMouseDownFunction(sovHolderIcon): 377 378 def OnMouseDownFunction(button): 379 SovHolderIcon.OnMouseDown(sovHolderIcon, button) 380 itemID = sovHolderIcon.structureInfo.get('itemID', None) 381 if itemID: 382 GetMenuService().TryExpandActionMenu(itemID, sovHolderIcon) 383 384 return OnMouseDownFunction 385 386 xPos = -4 387 for structureTypeID, structureInfo in structureInfosByTypeID.iteritems(): 388 sovHolderIcon = SovHolderIcon(parent=self.sovInfoContainer, left=xPos, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, structureInfo=structureInfo, showStructureStatusBar=True) 389 sovHolderIcon.OnMouseDown = GetMouseDownFunction(sovHolderIcon) 390 self.sovHolderIcons.append(sovHolderIcon) 391 xPos += sovHolderIcon.width + 6 392 393 hubInfo = structureInfosByTypeID[appConst.typeInfrastructureHub] 394 isCapital = hubInfo.get('isCapital', False) 395 capitalOwnerID = hubInfo.get('allianceID', None) 396 self.cynoJammerIcon = CynoJammerIcon(parent=self.sovInfoContainer, iconSize=32, align=uiconst.CENTERLEFT, pos=(xPos, 397 0, 398 40, 399 40)) 400 xPos += self.cynoJammerIcon.width + 6 401 self.ShowMultiplyBonusesIcon(self.sovInfoContainer, isCapital, xPos, capitalOwnerID) 402 403 def CheckNearest(self): 404 if not session.solarsystemid or not self.headerLabelCont: 405 self.locationTimer = None 406 return 407 nearestBall = self.GetNearestBall() 408 if nearestBall and self.nearby != nearestBall.id: 409 self.UpdateNearestOrStationLocationInfo(nearestBall) 410 411 def GetNearestBall(self, fromBall = None, getDist = 0): 412 ballPark = sm.GetService('michelle').GetBallpark() 413 if not ballPark: 414 return 415 lst = [] 416 for ballID, ball in ballPark.balls.iteritems(): 417 slimItem = ballPark.GetInvItem(ballID) 418 if slimItem and slimItem.groupID in self.validNearBy: 419 if fromBall: 420 dist = trinity.TriVector(ball.x - fromBall.x, ball.y - fromBall.y, ball.z - fromBall.z).Length() 421 lst.append((dist, ball)) 422 else: 423 lst.append((ball.surfaceDist, ball)) 424 425 lst.sort() 426 if getDist: 427 return lst[0] 428 if lst: 429 return lst[0][1] 430 431 def OnSolarsystemSovStructureChanged(self, solarsystemID, whatChanged, sourceItemID = None): 432 if sourceItemID is None: 433 if session.solarsystemid2 == solarsystemID and session.charid: 434 self.UpdateSOVLocationInfo() 435 return 436 for buttonIcon in self.sovHolderIcons: 437 if ShouldUpdateStructureInfo(buttonIcon.structureInfo, sourceItemID): 438 newStructureInfo = self.sovSvc.GetSpecificSovStructuresInfoInSolarSystem(solarsystemID, sourceItemID) 439 buttonIcon.SolarsystemSovStructureChanged(sourceItemID, newStructureInfo, whatChanged) 440 return 441 442 def OnCapitalSystemChanged(self, change): 443 allianceID, oldSolarSystemID, newSolarSystemID = change 444 if oldSolarSystemID is None: 445 call_after_simtime_delay(self.UpdateSOVLocationInfo, 30) 446 else: 447 self.UpdateSOVLocationInfo() 448 449 def OnCynoJammerChanged(self, solarsystemID, onlineSimTime): 450 if solarsystemID != session.solarsystemid2: 451 return 452 if self.cynoJammerIcon: 453 self.cynoJammerIcon.UpdateIconState(onlineSimTime) 454 455 def OnCurrentSystemSecurityChanged(self): 456 self.UpdateMainLocationInfo() 457 458 def OnWarzoneOccupationStateUpdated_Local(self): 459 self.UpdateLocationInfo() 460 461 def OnDynamicBountyUpdate_Local(self): 462 self.UpdateDynamicResourceInfo() 463 464 def UpdateEmanationLockInfo(self): 465 lock_details = GateLockController.get_instance(get_gate_lock_messenger(sm.GetService('publicGatewaySvc'))).get_current_system_lock() 466 self.emanationLockInfoContainer.Flush() 467 self.emanationLockInfoContainer.display = False 468 if lock_details is None: 469 return 470 self.emanationLockInfoContainer.display = True 471 gateID = lock_details.gate_id 472 gateName = cfg.evelocations.Get(gateID).locationName 473 gateTypeID = self._GetStargateTypeID(gateID) 474 if not gateTypeID: 475 return 476 gateLabelText = "<url=showinfo:%d//%d alt='%s'>%s</url>" % (gateTypeID, 477 gateID, 478 localization.GetByLabel('UI/Map/StarMap/EmanationLockMarkerTooltip', gate_name=gateName), 479 localization.GetByLabel('UI/Common/ItemTypes/Gate', gate_name=gateName)) 480 spriteLayoutCont = Container(parent=self.emanationLockInfoContainer, name='detailsCont', align=uiconst.CENTERLEFT, pos=(0, 0, 40, 40)) 481 Sprite(parent=spriteLayoutCont, align=uiconst.CENTER, texturePath='res:/UI/Texture/eveicon/system_icons/link_16px.png', pos=(0, 0, 16, 16)) 482 gateLabel = EveLabelMedium(parent=self.emanationLockInfoContainer, text=gateLabelText, left=spriteLayoutCont.width + 4, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 483 gateLabel.OnMouseDownWithUrl = self._on_mouse_down_with_url 484 485 def _GetStargateTypeID(self, gateID): 486 slimItem = sm.GetService('michelle').GetItem(gateID) 487 if slimItem and slimItem.typeID: 488 return slimItem.typeID 489 systemInfo = cfg.mapSolarSystemContentCache.get(session.solarsystemid2, None) 490 if not systemInfo: 491 return 492 gateInfo = systemInfo.stargates.get(gateID, None) 493 if not gateInfo: 494 return 495 return gateInfo.typeID 496 497 @threadutils.threaded 498 def _on_mouse_down_with_url(self, url, *args): 499 try: 500 parsed = evelink.parse_show_info_url(url) 501 except Exception: 502 log.LogWarn('Failed to parse URL') 503 return 504 505 if parsed.item_id is None or not idCheckers.IsStargate(parsed.item_id): 506 return 507 GetMenuService().TryExpandActionMenu(itemID=parsed.item_id, clickedObject=self, typeID=parsed.type_id) 508 509 def OnEmanationLockUpdated(self, lock_details): 510 self.UpdateEmanationLockInfo()