stargateDeploymentCont.py (6006B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\deployment\stargateDeploymentCont.py 2 from carbonui.control.combo import Combo 3 from carbonui.primitives.container import Container 4 from carbonui.util.bunch import Bunch 5 import eve.client.script.parklife.states as stateConst 6 from eve.client.script.ui.control.eveScroll import Scroll 7 from eve.client.script.ui.shared.stateFlag import GetStateFlagFromData 8 from eve.client.script.ui.structure.deployment.stargateSystemEntry import StargateDestSystemsEntry 9 from localization import GetByLabel 10 from localization.formatters import FormatNumeric 11 from utillib import KeyVal 12 import carbonui.const as uiconst 13 OPT_ALL_SYSTEMS = 1 14 OPT_WITH_GATES_POINTING_HERE = 2 15 16 class StargateDeploymentCont(Container): 17 18 def ApplyAttributes(self, attributes): 19 Container.ApplyAttributes(self, attributes) 20 solarSystemName = cfg.evelocations.Get(session.solarsystemid2).name 21 options = [(GetByLabel('UI/Structures/Deployment/AllSolarsystems'), OPT_ALL_SYSTEMS), (GetByLabel('UI/Structures/Deployment/SystemsLinkedHere', solarSystemName=solarSystemName), OPT_WITH_GATES_POINTING_HERE)] 22 topCont = Container(parent=self, align=uiconst.TOTOP, height=20) 23 self.filterCombo = Combo(parent=topCont, align=uiconst.TOLEFT, options=options, callback=self.LoadListFromCombo, width=120) 24 self.scroll = Scroll(parent=self, padding=const.defaultPadding, id='StargateDeploymentCont') 25 self.scroll.multiSelect = False 26 self.scroll.GetStringFromNode = self.GetStringsFromNode 27 28 def LoadListFromCombo(self, *args): 29 self._LoadList() 30 31 def LoadListAndSetFilter(self, firstTime): 32 if firstTime: 33 jumpBridgesInRangeBySolarSystemID = sm.GetService('structureDeployment').GetNearbyJumpBridges() 34 aBridgePointsToSystem = any((x.alignedToCurrentSystem for x in jumpBridgesInRangeBySolarSystemID.itervalues())) 35 if aBridgePointsToSystem: 36 self.filterCombo.SetValue(OPT_WITH_GATES_POINTING_HERE) 37 else: 38 self.filterCombo.SetValue(OPT_ALL_SYSTEMS) 39 self._LoadList() 40 41 def _LoadList(self): 42 filterCombValue = self.filterCombo.GetValue() 43 structureDeploymentSvc = sm.GetService('structureDeployment') 44 destinationSolarsystemID = structureDeploymentSvc.GetDestinationSolarsystemID() 45 nearbySolarSystemsDict = structureDeploymentSvc.GetSystemsInLightYearDistanceForJumpGateDict(session.solarsystemid) 46 cfg.evelocations.Prime(nearbySolarSystemsDict.keys()) 47 jumpBridgesInRangeBySolarSystemID = sm.GetService('structureDeployment').GetNearbyJumpBridges() 48 pathFinderSvc = sm.GetService('clientPathfinderService') 49 facwarSvc = sm.GetService('facwar') 50 stateSvc = sm.GetService('stateSvc') 51 scrollList = [] 52 for eachSolarSystemID, dist in nearbySolarSystemsDict.iteritems(): 53 jumpGate = jumpBridgesInRangeBySolarSystemID.get(eachSolarSystemID, None) 54 systemName = cfg.evelocations.Get(eachSolarSystemID).name 55 distText = GetByLabel('UI/CapitalNavigation/CapitalNavigationWindow/DistanceToSystem', lightYearDistance=dist) 56 numJumps = pathFinderSvc.GetJumpCountFromCurrent(eachSolarSystemID) 57 jumpsText = FormatNumeric(numJumps, decimalPlaces=0) 58 isSelected = eachSolarSystemID == destinationSolarsystemID 59 alignedToCurrentSystem = bool(jumpGate and jumpGate.alignedToCurrentSystem) 60 if filterCombValue == OPT_WITH_GATES_POINTING_HERE and not alignedToCurrentSystem: 61 continue 62 if jumpGate: 63 structureName = jumpGate.structureName 64 corpID = jumpGate.ownerID 65 else: 66 structureName = '' 67 corpID = None 68 if corpID: 69 warFactionID = facwarSvc.GetCorporationWarFactionID(corpID) 70 corpFlag = GetStateFlagFromData(KeyVal(ownerID=corpID, corpID=corpID, warFactionID=warFactionID)) 71 corpFlagInfo = stateSvc.GetStatePropsColorAndBlink(corpFlag) 72 else: 73 corpFlag = None 74 corpFlagInfo = None 75 node = Bunch(solarSystemID=eachSolarSystemID, systemName=systemName, decoClass=StargateDestSystemsEntry, jumpText=jumpsText, distText=distText, charIndex=systemName, OnClick=self.OnEntrySelected, isSelected=isSelected, corpFlagInfo=corpFlagInfo, jumpGate=jumpGate) 76 flagSortNumber = GetFlagSortNumber(corpFlag) 77 node.sortValues = [systemName, 78 dist, 79 numJumps, 80 (flagSortNumber, structureName.lower()), 81 (-alignedToCurrentSystem, -bool(jumpGate), flagSortNumber)] 82 scrollList.append(node) 83 84 noContentHint = GetByLabel('UI/Structures/Deployment/NoSolarsystemsFound') 85 self.scroll.Load(contentList=scrollList, headers=StargateDestSystemsEntry.GetHeaders(), noContentHint=noContentHint) 86 87 def OnEntrySelected(self, entry): 88 selectedNodes = self.scroll.GetSelected() 89 if not selectedNodes: 90 solarSystemID = None 91 else: 92 solarSystemID = selectedNodes[0].solarSystemID 93 structureDeployment = sm.GetService('structureDeployment') 94 structureDeployment.SetDestinationSolarsystemID(solarSystemID) 95 96 def GetStringsFromNode(self, node): 97 return StargateDestSystemsEntry.GetStringFromNode(node) 98 99 100 def GetFlagSortNumber(corpFlag): 101 if corpFlag in flagOrder: 102 return -flagOrder.index(corpFlag) 103 return corpFlag 104 105 106 flagOrder = [stateConst.flagStandingHorrible, 107 stateConst.flagStandingBad, 108 stateConst.flagAlliesAtWar, 109 stateConst.flagAtWarMilitia, 110 stateConst.flagNoStanding, 111 stateConst.flagStandingNeutral, 112 stateConst.flagAlliesAtWar, 113 stateConst.flagSameMilitia, 114 stateConst.flagStandingGood, 115 stateConst.flagStandingHigh, 116 stateConst.flagSameAlliance, 117 stateConst.flagSamePlayerCorp]