otherPinManager.py (6046B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\planet\otherPinManager.py 2 import evetypes 3 import uthread 4 from eve.common.script.util.planetCommon import SurfacePoint 5 from .planetUIPins import OtherPlayersPin 6 7 class OtherPinManager: 8 __notifyevents__ = [] 9 10 def __init__(self): 11 sm.RegisterNotify(self) 12 self.currentOtherExpandedCommandPin = None 13 self.otherPlayerPinsByPinID = {} 14 self.otherPlayerVisiblePins = [] 15 self.otherPlayerExtractors = [] 16 17 def Close(self): 18 sm.UnregisterNotify(self) 19 self.currentOtherExpandedCommandPin = None 20 self.otherPlayerPinsByPinID = None 21 self.otherPlayerVisiblePins = None 22 self.otherPlayerExtractors = None 23 24 def OnPlanetViewOpened(self): 25 self.planetUISvc = sm.GetService('planetUI') 26 uthread.new(self.RenderCommandCentersOfOtherCharacters) 27 28 def OnPlanetViewClosed(self): 29 self.ShowOrHideOtherCharactersPins(show=False) 30 31 def RenderCommandCentersOfOtherCharacters(self): 32 if not settings.user.ui.Get('planetShowOtherCharactersPins', True): 33 return 34 commandCenters = self.GetCommandCentersOfOtherCharacters() 35 for charid, cc in commandCenters.iteritems(): 36 if charid == session.charid: 37 continue 38 sp = SurfacePoint(theta=cc.longitude, phi=cc.latitude) 39 pin = OtherPlayersPin(sp, cc.pinID, cc.typeID, cc.ownerID, self.planetUISvc.pinOthersTransform) 40 self.otherPlayerPinsByPinID[cc.pinID] = pin 41 42 self.planetUISvc.curveLineDrawer.SubmitLineset('otherLinks') 43 44 def ShowOrHideOtherCharactersPins(self, show): 45 if show: 46 showOtherPins = settings.user.ui.Set('planetShowOtherCharactersPins', True) 47 self.RenderCommandCentersOfOtherCharacters() 48 else: 49 showOtherPins = settings.user.ui.Set('planetShowOtherCharactersPins', False) 50 self.HideOtherCharactersNetwork() 51 for pin in self.otherPlayerPinsByPinID.values(): 52 pin.Remove() 53 self.otherPlayerPinsByPinID = {} 54 55 def RenderOtherCharactersNetwork(self, charid): 56 linkColor = (0.0, 1.0, 1.0, 1.0) 57 linkBgColor = (0.0, 0.0, 0.0, 0.3) 58 pins, links = self.GetOtherCharactersNetwork(charid) 59 self.HideOtherCharactersNetwork() 60 for pinData in pins: 61 if evetypes.GetGroupID(pinData.typeID) == const.groupCommandPins: 62 self.currentOtherExpandedCommandPin = self.otherPlayerPinsByPinID[pinData.pinID] 63 self.currentOtherExpandedCommandPin.RenderAsActive() 64 continue 65 sp = SurfacePoint(theta=pinData.longitude, phi=pinData.latitude) 66 pin = OtherPlayersPin(sp, pinData.pinID, pinData.typeID, pinData.ownerID, self.planetUISvc.pinOthersTransform, isActive=True) 67 self.otherPlayerVisiblePins.append(pin) 68 self.otherPlayerPinsByPinID[pinData.pinID] = pin 69 70 for link in links: 71 sp1 = self.otherPlayerPinsByPinID[link[0]].surfacePoint 72 sp2 = self.otherPlayerPinsByPinID[link[1]].surfacePoint 73 length = sp1.GetDistanceToOther(sp2) 74 texWidth = 600.0 * length 75 lineID = self.planetUISvc.curveLineDrawer.DrawArc('otherLinks', sp1, sp2, 5.0, linkBgColor, linkBgColor) 76 numSegments = max(1, int(length * 25.0)) 77 self.planetUISvc.curveLineDrawer.SetLineSetNumSegments('otherLinks', lineID, numSegments) 78 self.planetUISvc.curveLineDrawer.ChangeLineAnimation('otherLinks', lineID, linkColor, 0.0, texWidth) 79 80 self.planetUISvc.curveLineDrawer.SubmitLineset('otherLinks') 81 82 def HideOtherCharactersNetwork(self): 83 for pin in self.otherPlayerVisiblePins: 84 pin.Remove() 85 86 self.otherPlayerVisiblePins = [] 87 self.planetUISvc.curveLineDrawer.ClearLines('otherLinks') 88 if self.currentOtherExpandedCommandPin: 89 self.currentOtherExpandedCommandPin.RenderAsDefault() 90 self.currentOtherExpandedCommandPin = None 91 92 def RenderOtherPlayersExtractors(self, resourceTypeID): 93 self.HideOtherPlayersExtractors() 94 extractorData = self.GetExtractorsOfOtherCharacters(resourceTypeID) 95 if not extractorData: 96 return 97 for pinData in extractorData: 98 sp = SurfacePoint(theta=pinData.longitude, phi=pinData.latitude) 99 pin = OtherPlayersPin(sp, pinData.pinID, pinData.typeID, pinData.ownerID, self.planetUISvc.pinOthersTransform, isActive=True) 100 self.otherPlayerExtractors.append(pin) 101 self.otherPlayerPinsByPinID[pinData.pinID] = pin 102 103 def HideOtherPlayersExtractors(self): 104 for pin in self.otherPlayerExtractors: 105 pin.Remove() 106 107 self.otherPlayerExtractors = [] 108 109 def GetCommandCentersOfOtherCharacters(self): 110 if not self.planetUISvc.planet: 111 return 112 return sm.GetService('planetSvc').GetPlanetCommandPins(self.planetUISvc.planet.planetID) 113 114 def GetExtractorsOfOtherCharacters(self, resourceTypeID): 115 if self.planetUISvc.planet is None: 116 return 117 extractors = sm.GetService('planetSvc').GetExtractorsForPlanet(self.planetUISvc.planet.planetID) 118 ret = [] 119 for extractor in extractors: 120 extractedType = sm.GetService('godma').GetTypeAttribute(extractor.typeID, const.attributeHarvesterType) 121 if extractedType != resourceTypeID: 122 continue 123 if extractor.ownerID == session.charid: 124 continue 125 ret.append(extractor) 126 127 return ret 128 129 def GetOtherCharactersNetwork(self, charid): 130 if self.planetUISvc.planet is None: 131 return 132 return sm.GetService('planetSvc').GetColonyForCharacter(self.planetUISvc.planet.planetID, charid) 133 134 def GetPinMenuOther(self, pinID): 135 pin = self.otherPlayerPinsByPinID.get(pinID) 136 if pin: 137 return pin.GetMenu()