navigation_systemmap.py (6422B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\maps\navigation_systemmap.py 2 import evecamera 3 import trinity 4 import blue 5 import geo2 6 import carbonui.const as uiconst 7 import log 8 from carbonui.control.layer import LayerCore 9 from carbonui.uicore import uicore 10 from eve.client.script.ui.shared.maps import maputils 11 from eve.client.script.ui.shared.maps.mapcommon import SYSTEMMAP_SCALE 12 13 class SystemMapLayer(LayerCore): 14 __update_on_reload__ = 0 15 default_align = uiconst.TOALL 16 default_cursor = uiconst.UICURSOR_DRAGGABLE 17 activeManipAxis = None 18 _isPicked = False 19 20 def SetInterest(self, itemID, interpolate = True): 21 solarsystem = sm.GetService('systemmap').GetCurrentSolarSystem() 22 if solarsystem is None: 23 log.LogTrace('No solar system (SystemmapNav::SetInterest)') 24 return 25 endPos = None 26 for tf in solarsystem.children: 27 tfName = getattr(tf, 'name', None) 28 if tfName is None: 29 continue 30 if tfName.startswith('systemParent_'): 31 for stf in tf.children: 32 stfName = getattr(stf, 'name', None) 33 if stfName is None: 34 continue 35 try: 36 prefix, stfItemID = stfName.split('_') 37 if prefix == 'scanResult': 38 stfItemID = ('result', stfItemID) 39 else: 40 stfItemID = int(stfItemID) 41 except: 42 continue 43 44 if stfItemID == itemID: 45 endPos = stf.worldTransform[3][:3] 46 break 47 48 if endPos: 49 break 50 elif tfName.startswith('bm_') and isinstance(itemID, tuple) and itemID[0] == 'bookmark': 51 tfItemID = int(tfName.split('_')[1]) 52 if tfItemID == itemID[1]: 53 endPos = tf.worldTransform[3][:3] 54 break 55 elif tfName.endswith(str(itemID)): 56 endPos = tf.worldTransform[3][:3] 57 break 58 59 if endPos is None and itemID == session.shipid: 60 endPos = maputils.GetMyPos() 61 endPos.Scale(SYSTEMMAP_SCALE) 62 endPos = (endPos.x, endPos.y, endPos.z) 63 self.FocusOnTrinityPoint(endPos, interpolate=interpolate) 64 65 def FocusOnPoint(self, endPos): 66 scaledEndPos = geo2.Vec3Scale(endPos, SYSTEMMAP_SCALE) 67 self.FocusOnTrinityPoint(scaledEndPos) 68 69 def FocusOnTrinityPoint(self, triVector, interpolate = True): 70 if triVector and interpolate: 71 now = blue.os.GetSimTime() 72 cameraParent = self.GetCameraParent() 73 if cameraParent.translationCurve: 74 startPos = cameraParent.translationCurve.GetVectorAt(now) 75 startPos = (startPos.x, startPos.y, startPos.z) 76 else: 77 startPos = cameraParent.translation 78 vc = trinity.Tr2CurveVector3() 79 vc.AddKey(0.0, startPos) 80 vc.AddKey(0.5, triVector) 81 cameraParent.translationCurve = trinity.Tr2TranslationAdapter() 82 cameraParent.translationCurve.curve = vc 83 cameraParent.useCurves = 1 84 elif triVector: 85 cameraParent = self.GetCameraParent() 86 cameraParent.translationCurve = None 87 cameraParent.translation = triVector 88 89 def GetCameraParent(self): 90 camera = sm.GetService('sceneManager').GetRegisteredCamera(evecamera.CAM_SYSTEMMAP) 91 return camera.GetCameraParent() 92 93 def OnMouseMove(self, *args): 94 self.sr.hint = '' 95 lib = uicore.uilib 96 camera = sm.GetService('sceneManager').GetRegisteredCamera(evecamera.CAM_SYSTEMMAP) 97 dx = lib.dx 98 dy = lib.dy 99 if not self._isPicked: 100 return 101 if lib.leftbtn and not lib.rightbtn: 102 fov = camera.fieldOfView 103 camera.OrbitParent(-dx * fov * 0.1, dy * fov * 0.1) 104 sm.GetService('systemmap').SortBubbles() 105 elif lib.rightbtn and not lib.leftbtn: 106 cameraParent = self.GetCameraParent() 107 if cameraParent.translationCurve: 108 pos = cameraParent.translationCurve.GetVectorAt(blue.os.GetSimTime()) 109 cameraParent.translationCurve = None 110 cameraParent.translation = (pos.x, pos.y, pos.z) 111 scalefactor = camera.translationFromParent * (camera.fieldOfView * 0.001) 112 offset = (dx * scalefactor, -dy * scalefactor, 0.0) 113 offset = geo2.QuaternionTransformVector(camera.rotationAroundParent, offset) 114 cameraParent.translation = geo2.Vec3Subtract(cameraParent.translation, offset) 115 elif lib.leftbtn and lib.rightbtn: 116 modifier = uicore.mouseInputHandler.GetCameraZoomModifier() 117 camera.Dolly(modifier * -(dy * 0.01) * abs(camera.translationFromParent)) 118 camera.translationFromParent = camera.CheckTranslationFromParent(camera.translationFromParent) 119 120 def OnMouseEnter(self, *args): 121 if sm.GetService('ui').IsUiVisible(): 122 uicore.layer.main.state = uiconst.UI_PICKCHILDREN 123 124 def OnMouseDown(self, button): 125 systemmap = sm.GetService('systemmap') 126 self._isPicked = True 127 self.SetOrder(0) 128 systemmap.CollapseBubbles() 129 systemmap.SortBubbles() 130 131 def OnMouseUp(self, button): 132 if sm.GetService('ui').IsUiVisible(): 133 uicore.layer.main.state = uiconst.UI_PICKCHILDREN 134 if not (uicore.uilib.leftbtn or uicore.uilib.rightbtn): 135 self._isPicked = False 136 if button == 1: 137 self.SetOrder(-1) 138 return 139 self.SetOrder(-1) 140 sm.GetService('systemmap').SortBubbles() 141 sm.GetService('ui').ForceCursorUpdate() 142 143 def OnMouseWheel(self, *args): 144 modifier = uicore.mouseInputHandler.GetCameraZoomModifier() 145 self.ZoomBy(modifier * uicore.uilib.dz) 146 return 1 147 148 def ZoomBy(self, amount): 149 camera = sm.GetService('sceneManager').GetRegisteredCamera(evecamera.CAM_SYSTEMMAP) 150 camera.Dolly(amount * 0.001 * abs(camera.translationFromParent)) 151 camera.translationFromParent = camera.CheckTranslationFromParent(camera.translationFromParent) 152 153 def _OnClose(self): 154 pass