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

fwMapStar.py (6316B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\fwwarzone\client\dashboard\fwMapStar.py
      2 import eveformat.client
      3 import logging
      4 from carbonui import TextColor, uiconst
      5 from carbonui.control.buttonIcon import ButtonIcon
      6 from carbonui.primitives.layoutGrid import LayoutGrid
      7 from carbonui.primitives.sprite import Sprite
      8 from carbonui.primitives.transform import Transform
      9 from eve.client.script.ui.control.eveLabel import EveLabelLarge
     10 from factionwarfare.client.text import GetSystemCaptureStatusText
     11 from fwwarzone.client.dashboard.const import ADJACENCY_TO_LABEL_TEXT, FACTION_ID_TO_COLOR, FACTION_ID_TO_FLAT_ICON, SYSTEM_NOT_PART_OF_WARZONE_TEXT, SYSTEM_BULWARK_TEXT
     12 from fwwarzone.client.dashboard.gauges.advantageWidget import AdvantageWidget
     13 from fwwarzone.client.dashboard.gauges.contestedGauge import ContestedFWSystemGauge
     14 from localization import GetByLabel
     15 logger = logging.getLogger(__name__)
     16 
     17 class FWMapStar(ButtonIcon):
     18 
     19     def ApplyAttributes(self, attributes):
     20         self.system = attributes.get('system')
     21         self.systemId = self.system.systemId
     22         self.warzoneId = attributes.get('warzoneId')
     23         ButtonIcon.ApplyAttributes(self, attributes)
     24 
     25     def LoadTooltipPanel(self, tooltipPanel, *args):
     26         if self.system.isNavigationSystem:
     27             self._ConstructNavigationSystemTooltip(tooltipPanel)
     28         else:
     29             self._ConstructWarzoneSystemTooltip(tooltipPanel)
     30 
     31     def _isDefendingFaction(self, factionId, systemId):
     32         return sm.GetService('fwWarzoneSvc').GetAllOccupationStates()[self.warzoneId][systemId].occupierID == factionId
     33 
     34     def _ConstructNavigationSystemTooltip(self, tooltipPanel):
     35         solarSystem = cfg.mapSystemCache.get(self.systemId, None)
     36         if solarSystem:
     37             factionId = getattr(solarSystem, 'factionID', None)
     38             secStatusText = eveformat.client.hint(hint=GetByLabel('UI/Map/StarMap/SecurityStatus'), text=eveformat.client.solar_system_security_status(self.systemId))
     39             label = EveLabelLarge(text=u'{} {}'.format(cfg.evelocations.Get(self.systemId).name, secStatusText), bold=True)
     40             ownerLabel = None
     41             logo = None
     42             if factionId:
     43                 ownerLabel = EveLabelLarge(text=cfg.eveowners.Get(factionId).name, opacity=1.0)
     44                 if factionId in FACTION_ID_TO_FLAT_ICON:
     45                     logo = Sprite(texturePath=FACTION_ID_TO_FLAT_ICON[factionId], align=uiconst.TOPLEFT, width=32, height=32, state=uiconst.UI_DISABLED, color=FACTION_ID_TO_COLOR[factionId])
     46             bulwarkText = self._GetBulwarkText()
     47             containerGrid = LayoutGrid(rows=2, columns=1, margin=10, cellSpacing=5)
     48             topRow = LayoutGrid(columns=2, rows=3, cellSpacing=1, cellPadding=0)
     49             if factionId:
     50                 topRow.AddCell(logo, rowSpan=2)
     51             topRow.AddCell(label)
     52             if factionId:
     53                 topRow.AddCell(ownerLabel)
     54             bottomRow = LayoutGrid(columns=1, cellSpacing=8)
     55             if bulwarkText:
     56                 EveLabelLarge(parent=bottomRow, text=bulwarkText, maxWidth=150)
     57             EveLabelLarge(parent=bottomRow, text=SYSTEM_NOT_PART_OF_WARZONE_TEXT, maxWidth=150)
     58             containerGrid.AddCell(topRow)
     59             containerGrid.AddCell(bottomRow)
     60             tooltipPanel.AddCell(containerGrid)
     61 
     62     def _GetBulwarkText(self):
     63         try:
     64             if sm.GetService('fwWarzoneSvc').GetMapTagProvider().is_bulwark_system(self.systemId):
     65                 return SYSTEM_BULWARK_TEXT
     66         except Exception:
     67             logger.exception('Failed to check if bulwark system')
     68 
     69     def _ConstructWarzoneSystemTooltip(self, tooltipPanel):
     70         if self.system.occupationState.adjacencyState == -1:
     71             return
     72         factionId = self.system.occupationState.occupierID
     73         attackerFactionID = self.system.occupationState.attackerID
     74         contestedGaugeTransform = Transform(width=50, height=50)
     75         secStatusText = eveformat.client.hint(hint=GetByLabel('UI/Map/StarMap/SecurityStatus'), text=eveformat.client.solar_system_security_status(self.systemId))
     76         systemNameLabel = EveLabelLarge(text=u'%s %s' % (cfg.evelocations.Get(self.systemId).name, secStatusText), bold=True)
     77         victoryPointState = sm.GetService('fwVictoryPointSvc').GetVictoryPointState(self.systemId)
     78         stateText = GetSystemCaptureStatusText(victoryPointState)
     79         contestedLabelStatus = EveLabelLarge(text=stateText, bold=True, color=TextColor.HIGHLIGHT)
     80         occupierLabel = EveLabelLarge(text=cfg.eveowners.Get(factionId).name)
     81         ContestedFWSystemGauge(parent=contestedGaugeTransform, align=uiconst.TOPLEFT, systemId=self.systemId, radius=25, attackerColor=FACTION_ID_TO_COLOR[attackerFactionID], defenderColor=FACTION_ID_TO_COLOR[factionId], adjacencyState=self.system.occupationState.adjacencyState, animateIn=False)
     82         informationLabel = EveLabelLarge(text=GetByLabel('UI/FactionWarfare/frontlinesDashboard/thisSystemIsAdjacencyLabel', adjacencyState=ADJACENCY_TO_LABEL_TEXT[self.system.occupationState.adjacencyState]))
     83         advantageGaugeCont = Transform(height=50, width=200)
     84         advantageSubheaderLabel = EveLabelLarge(text=GetByLabel('UI/FactionWarfare/frontlinesDashboard/advantageTitleLabel'))
     85         AdvantageWidget(systemId=self.systemId, name='AdvantageWidget', parent=advantageGaugeCont, align=uiconst.TOTOP, animateIn=False)
     86         headerLabelGrid = LayoutGrid(rows=3, columns=1, cellPadding=0)
     87         headerLabelGrid.AddCell(systemNameLabel)
     88         headerLabelGrid.AddCell(occupierLabel)
     89         headerLabelGrid.AddCell(contestedLabelStatus)
     90         headerGrid = LayoutGrid(rows=1, columns=2, cellPadding=5)
     91         headerGrid.AddCell(contestedGaugeTransform)
     92         headerGrid.AddCell(headerLabelGrid)
     93         advantageGrid = LayoutGrid(rows=2, columns=1)
     94         advantageGrid.AddCell(advantageSubheaderLabel)
     95         advantageGrid.AddCell(advantageGaugeCont)
     96         containerGrid = LayoutGrid(rows=3, columns=1, cellPadding=5, margin=10)
     97         containerGrid.AddCell(headerGrid)
     98         containerGrid.AddCell(informationLabel)
     99         containerGrid.AddCell(advantageGrid)
    100         tooltipPanel.AddCell(containerGrid)
    101 
    102     def GetMenu(self):
    103         return sm.GetService('menu').CelestialMenu(self.systemId)