panelFactionalWarfare.py (7766B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panelFactionalWarfare.py 2 import carbonui 3 import carbonui.text.styles 4 import evelink 5 from carbonui.control.scrollContainer import ScrollContainer 6 from carbonui.primitives.container import Container 7 from carbonui import const as uiconst, TextColor 8 from carbonui.primitives.containerAutoSize import ContainerAutoSize 9 from carbonui.util.color import Color 10 from characterdata.factions import get_faction_name 11 from eve.client.script.ui.control.eveIcon import OwnerIcon 12 from eve.client.script.ui.control.eveLabel import EveLabelMedium 13 from eve.client.script.ui.shared.factionalWarfare.fwSystemBenefitIcon import FWSystemBenefitIcon 14 from eve.common.script.util.facwarCommon import BENEFITS_BY_LEVEL 15 from evelink.client import owner_link 16 from factionwarfare.client.text import GetSystemCaptureStatusText, GetSystemCaptureStatusHint 17 from fwwarzone.client.dashboard.const import ADJACENCY_TO_LABEL_SYSTEM_TEXT 18 from fwwarzone.client.dashboard.gauges.advantageWidget import AdvantageWidget 19 from fwwarzone.client.dashboard.gauges.contestedGauge import ContestedFWSystemGauge 20 from fwwarzone.client.util import GetAttackerDefenderColors, GetSystemCaptureStatusColorFromVp 21 from localization import GetByLabel 22 import inventorycommon.const as invConst 23 iconSize = 48 24 textPad = 10 25 26 class PanelFactionalWarfare(Container): 27 28 def ApplyAttributes(self, attributes): 29 super(PanelFactionalWarfare, self).ApplyAttributes(attributes) 30 self.solarsystemID = attributes.solarsystemID 31 self.fwVictoryPointSvc = sm.GetService('fwVictoryPointSvc') 32 self.fwWarzoneSvc = sm.GetService('fwWarzoneSvc') 33 self.facWarSvc = sm.GetService('facwar') 34 myScrollCont = ScrollContainer(parent=self, padding=const.defaultPadding) 35 ownerCont = ContainerAutoSize(name='ownerCont', parent=myScrollCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=iconSize) 36 self.ownerCont = Container(name='ownerCont', parent=ownerCont, align=uiconst.TOLEFT, width=iconSize + textPad) 37 self.occupierIcon = OwnerIcon(name='occupierIcon', parent=self.ownerCont, align=uiconst.CENTER, pos=(0, 38 0, 39 iconSize, 40 iconSize)) 41 self.occupierNameLabel = EveLabelMedium(name='occupierNameLabel', parent=ownerCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) 42 self.originalOwnerLabel = EveLabelMedium(name='originalOwnerLabel', parent=ownerCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) 43 constestedCont = ContainerAutoSize(name='constestedCont', parent=myScrollCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padTop=20, minHeight=iconSize) 44 self.gaugeCont = Container(name='gaugeCont', parent=constestedCont, align=uiconst.TOLEFT, width=iconSize + textPad) 45 self.controlGauge = ContestedFWSystemGauge(parent=self.gaugeCont, align=uiconst.CENTER, systemId=self.solarsystemID, radius=int(iconSize / 2)) 46 self.adjacencyLabel = EveLabelMedium(name='adjacencyLabel', parent=constestedCont, align=uiconst.TOTOP) 47 self.systemStatusLabel = EveLabelMedium(name='systemStatusLabel', parent=constestedCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) 48 upgradeCont = ContainerAutoSize(name='upgradeCont', parent=myScrollCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padTop=20, minHeight=iconSize) 49 self.benefitCont = Container(name='benefitCont', parent=upgradeCont, align=uiconst.TOLEFT, alignMode=uiconst.TOTOP) 50 self.systemLevelLabel = EveLabelMedium(name='systemLevelLabel', parent=upgradeCont, align=uiconst.TOTOP) 51 advantageCont = ContainerAutoSize(name='advantageCont', parent=myScrollCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padTop=10) 52 self.advantageLabel = EveLabelMedium(name='advantageLabel', parent=advantageCont, align=uiconst.TOTOP, text=GetByLabel('UI/FactionWarfare/frontlinesDashboard/advantageTitleLabel')) 53 systemAdvantageWidget = AdvantageWidget(systemId=self.solarsystemID, name='AdvantageWidget', parent=advantageCont, align=uiconst.TOTOP, padRight=10) 54 55 def Load(self, *args): 56 self.UpdateOccupier() 57 self.UpdateGauge() 58 self.UpdateAdjacencyLabel() 59 self.UpdateSystemStatusLabel() 60 self.UpdateSystemLevel() 61 self.UpdateWidth() 62 63 def UpdateAdjacencyLabel(self): 64 fwOccupationState = self.fwWarzoneSvc.GetOccupationState(self.solarsystemID) 65 adjacencyText = '' 66 if fwOccupationState: 67 adjacencyText = ADJACENCY_TO_LABEL_SYSTEM_TEXT.get(fwOccupationState.adjacencyState, '') 68 self.adjacencyLabel.SetText(adjacencyText) 69 70 def UpdateOccupier(self): 71 occupierID = self.fwWarzoneSvc.GetSystemOccupier(self.solarsystemID) 72 newText = GetByLabel('UI/Agency/FactionWarfare/systemOccupierLabel', factionID=occupierID, typeID=invConst.typeFaction) 73 self.occupierNameLabel.SetText(newText) 74 self.occupierIcon.SetOwnerID(occupierID) 75 solarSystem = cfg.mapSystemCache.Get(self.solarsystemID) 76 ownerLink = owner_link(solarSystem.factionID) 77 ownerText = GetByLabel('UI/FactionWarfare/OriginalOwner', factionLink=ownerLink) 78 self.originalOwnerLabel.SetText(ownerText) 79 80 def UpdateGauge(self): 81 attackerColor, defenderColor = GetAttackerDefenderColors(self.solarsystemID) 82 self.controlGauge.SetGaugeColors(attackerColor, defenderColor) 83 victoryPointState = self.fwVictoryPointSvc.GetVictoryPointState(self.solarsystemID) 84 if victoryPointState: 85 value = victoryPointState.contestedFraction 86 else: 87 value = 0.0 88 self.controlGauge.UpdateChart(value) 89 fwOccupationState = self.fwWarzoneSvc.GetOccupationState(self.solarsystemID) 90 adjacencyState = fwOccupationState.adjacencyState if fwOccupationState else None 91 self.controlGauge.SetAdjacency(adjacencyState) 92 93 def UpdateSystemStatusLabel(self): 94 victoryPointState = self.fwVictoryPointSvc.GetVictoryPointState(self.solarsystemID) 95 systemStatusText = GetSystemCaptureStatusText(victoryPointState) 96 newStatusText = GetByLabel('UI/Agency/FactionWarfare/systemStatusLabel', systemStatusText=systemStatusText, color=Color.RGBtoHex(*GetSystemCaptureStatusColorFromVp(victoryPointState))) 97 self.systemStatusLabel.SetText(newStatusText) 98 self.systemStatusLabel.SetHint(GetSystemCaptureStatusHint(victoryPointState)) 99 100 def UpdateSystemLevel(self): 101 upgradeLevel = self.facWarSvc.GetSolarSystemUpgradeLevel(self.solarsystemID) 102 self.benefitCont.Flush() 103 if upgradeLevel is None: 104 factionID = self.facWarSvc.GetSystemOccupier(self.solarsystemID) 105 carbonui.text.styles.TextBody(state=uiconst.UI_NORMAL, parent=self.benefitCont, align=uiconst.TOLEFT, text=GetByLabel('UI/PirateInsurgencies/factionDoesNotGetSystemUpgrades', factionName=owner_link(factionID)), color=TextColor.WARNING) 106 return 107 self.systemLevelLabel.SetText(GetByLabel('UI/Agency/FactionWarfare/systemUpgradeLevel', level=upgradeLevel)) 108 width = 0 109 currentBenefits = BENEFITS_BY_LEVEL.get(upgradeLevel) 110 for i, (benefitType, benefitValue) in enumerate(reversed(currentBenefits)): 111 icon = FWSystemBenefitIcon(parent=self.benefitCont, align=uiconst.TOLEFT, left=10 if i else 0, benefitType=benefitType, benefitValue=benefitValue, opacity=1.0, width=26) 112 width += icon.left + icon.width 113 114 self.benefitCont.width = width + 10 115 116 def UpdateWidth(self): 117 maxWidth = max(self.ownerCont.width, self.gaugeCont.width, self.benefitCont.width) 118 self.ownerCont.width = self.gaugeCont.width = self.benefitCont.width = maxWidth