mapMarkerPin.py (9852B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\markers\mapMarkerPin.py 2 import math 3 import eveicon 4 from carbon.common.script.util.format import FmtDist 5 from carbonui.text.styles import TextDetail 6 from carbonui.primitives.base import ScaleDpi 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.sprite import Sprite 9 import eve.client.script.ui.shared.mapView.mapViewConst as mapViewConst 10 from carbonui.uianimations import animations 11 from eve.client.script.ui import eveColor 12 from eve.client.script.ui.shared.mapView.markers.mapMarkerBase import MarkerSolarSystemBased 13 from eve.client.script.ui.inflight.bracket import BracketShadowLabel 14 import carbonui.const as uiconst 15 import geo2 16 from eve.client.script.ui.shared.mapView.markers.mapMarkerTooltip import MarkerTooltipRowBase, MarkerTooltipWrapperBase 17 from carbonui.uicore import uicore 18 19 class MarkerPinBase(MarkerSolarSystemBased): 20 tooltipRowClass = MarkerTooltipRowBase 21 label = None 22 highlightFrame = None 23 texturePath = None 24 iconColor = (1, 1, 1, 1) 25 outlineTexturePath = 'res:/UI/Texture/Classes/MapView/Markers/pinStroke.png' 26 outlineColor = None 27 backgroundTexturePath = 'res:/UI/Texture/Classes/MapView/Markers/pinFill.png' 28 backgroundColor = None 29 pin_width = 18 30 pin_height = 24 31 content_width = 14 32 content_height = 14 33 overlapStackContainer = None 34 overlapMarkers = None 35 overlapEnabled = True 36 overlapSortValue = None 37 distanceSortEnabled = True 38 inRangeIndicator = None 39 distanceFadeAlphaNearFar = (0.0, mapViewConst.MAX_MARKER_DISTANCE) 40 trackingTransforms = None 41 42 def __init__(self, *args, **kwds): 43 self.highlightOnLoad = kwds.get('highlightOnLoad', False) 44 self.isAbstractMode = kwds.get('isAbstractMode', False) 45 self.texturePath = kwds.get('texturePath', self.texturePath) 46 self._marked_solar_system_ids = kwds.get('marked_solar_system_ids', set()) 47 MarkerSolarSystemBased.__init__(self, *args, **kwds) 48 self.projectBracket.offsetY = -ScaleDpi(25) 49 50 def Load(self): 51 self.pin_cont = Container(name='pin_cont', parent=self.markerContainer, state=uiconst.UI_NORMAL, pos=(0, 52 0, 53 self.pin_width, 54 self.pin_height), align=uiconst.CENTERBOTTOM) 55 self.pin_cont.OnClick = self.OnClick 56 self.LoadContent() 57 outlineColor = self.get_outline_color() 58 self.outlineSprite = Sprite(name='outline_sprite', parent=self.pin_cont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=self.outlineTexturePath, color=outlineColor if outlineColor else eveColor.WHITE) 59 backgroundColor = self.get_background_color() 60 self.backgroundSprite = Sprite(name='background_sprite', parent=self.pin_cont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=self.backgroundTexturePath, color=backgroundColor if backgroundColor else eveColor.GUNMETAL_GREY) 61 self.markerContainer.pos = (0, 62 0, 63 self.pin_width, 64 self.pin_height) 65 self.markerContainer.SetState(uiconst.UI_NORMAL) 66 if self.highlightOnLoad and not self.updated: 67 self.highlightOnLoad = False 68 self.HighlightLoad() 69 self.UpdateInRangeIndicatorState() 70 self.markerContainer.tooltipPanelClassInfo = MarkerTooltipWrapperBase() 71 if self.solarSystemID in self._marked_solar_system_ids: 72 self.SetUpsideDown() 73 74 def get_outline_color(self): 75 return self.outlineColor 76 77 def get_background_color(self): 78 return self.backgroundColor 79 80 def SetUpsideDown(self): 81 self.projectBracket.offsetY = ScaleDpi(25) 82 self.pin_cont.SetAlign(uiconst.CENTERTOP) 83 self.backgroundSprite.rotation = math.pi 84 self.outlineSprite.rotation = math.pi 85 86 def LoadContent(self): 87 if self.texturePath: 88 self.pin_icon = Sprite(name='pin_icon', parent=self.pin_cont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 89 -2, 90 self.content_width, 91 self.content_height), texturePath=self.texturePath) 92 else: 93 self.pin_label = TextDetail(name='pin_label', parent=self.pin_cont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, text=self.GetValue()) 94 95 def DestroyRenderObject(self): 96 MarkerSolarSystemBased.DestroyRenderObject(self) 97 if self.label and not self.label.destroyed: 98 self.label.Close() 99 self.label = None 100 101 def RegisterTrackingTransform(self, transform): 102 if self.trackingTransforms is None: 103 self.trackingTransforms = [] 104 if transform not in self.trackingTransforms: 105 self.trackingTransforms.append(transform) 106 transform.translation = self.position 107 108 def UnregisterTrackingTransform(self, transform): 109 if transform in self.trackingTransforms: 110 self.trackingTransforms.remove(transform) 111 112 def Close(self, *args): 113 MarkerSolarSystemBased.Close(self, *args) 114 self.trackingTransforms = None 115 116 def ResetAbstractMode(self, isAbstractMode): 117 self.isAbstractMode = isAbstractMode 118 119 def UpdateInRangeIndicatorState(self): 120 if self.inRangeIndicatorState: 121 pass 122 elif self.inRangeIndicator and not self.inRangeIndicator.destroyed: 123 self.inRangeIndicator.Close() 124 self.inRangeIndicator = None 125 126 def _IsMarkerVisibleAtZoomLevel(self): 127 cameraZoomValue = self.markerHandler.cameraZoomValue 128 visible = cameraZoomValue > mapViewConst.MAP2D_ZOOM_TUBE_BUBBLE 129 return visible 130 131 def GetMarkerOpacity(self, bracketCameraDistance, cameraZoomDistance): 132 if self.isAbstractMode and not self._IsMarkerVisibleAtZoomLevel(): 133 return 0.0 134 return super(MarkerPinBase, self).GetMarkerOpacity(bracketCameraDistance, cameraZoomDistance) 135 136 def UpdateSolarSystemPosition(self, solarSystemPosition): 137 self.mapPositionSolarSystem = solarSystemPosition 138 self.position = geo2.Vec3Add(solarSystemPosition, self.mapPositionLocal) 139 self.projectBracket.trackPosition = self.position 140 if self.trackingTransforms: 141 for each in self.trackingTransforms: 142 each.translation = self.position 143 144 def UpdateMapPositionLocal(self, mapPositionLocal, animate = False): 145 self.mapPositionLocal = mapPositionLocal 146 self.position = geo2.Vec3Add(self.mapPositionSolarSystem, mapPositionLocal) 147 self.SetBracketPosition(animate) 148 if self.trackingTransforms: 149 for each in self.trackingTransforms: 150 each.translation = self.position 151 152 def SetBracketPosition(self, animate = False): 153 if animate: 154 animations.MorphVector3(self.projectBracket, 'trackPosition', self.projectBracket.trackPosition, self.position, duration=0.6) 155 else: 156 self.projectBracket.trackPosition = self.position 157 158 def HighlightLoad(self): 159 fill = Sprite(parent=self.markerContainer, color=(1, 1, 1, 0), align=uiconst.CENTER, pos=(0, 0, 2, 2), texturePath='res:/UI/Texture/classes/MapView/markerFadeIn.png') 160 duration = 0.8 161 uicore.animations.MorphScalar(fill, 'pin_width', startVal=16, endVal=160, duration=duration) 162 uicore.animations.MorphScalar(fill, 'pin_height', startVal=16, endVal=160, duration=duration) 163 uicore.animations.MorphScalar(fill, 'opacity', startVal=0.5, endVal=0.0, duration=duration, callback=fill.Close) 164 165 def GetIconSpriteIdleOpacity(self): 166 return 1.0 167 168 def GetBackgroundSpriteIdleOpacity(self): 169 return 1.0 170 171 def UpdateActiveAndHilightState(self, *args, **kwds): 172 if self.markerContainer: 173 if self.hilightState or self.activeState: 174 if self.highlightFrame is None or self.highlightFrame.destroyed: 175 self.highlightFrame = Sprite(parent=self.markerContainer, pos=(0, 0, 30, 30), name='highlightFrame', state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Bracket/selectionCircle.png', align=uiconst.CENTER, color=(1.0, 1.0, 1.0, 0.3)) 176 self.highlightFrame.opacity = 0.5 if self.hilightState else 0.25 177 self.ShowLabel() 178 else: 179 if self.highlightFrame and not self.highlightFrame.destroyed: 180 self.highlightFrame.opacity = 0.0 181 if self.label: 182 self.label.Close() 183 184 def GetLabelText(self): 185 displayName = self.GetDisplayText() 186 distance = self.GetDistance() 187 if distance is not None: 188 displayName += ' ' + FmtDist(distance) 189 return displayName 190 191 def GetValue(self): 192 return '' 193 194 def ShowLabel(self): 195 if not self.label or self.label.destroyed: 196 self.label = BracketShadowLabel(parent=self.markerContainer.parent, name='marker_label', align=uiconst.TOPLEFT, text=self.GetBracketLabelText(), bracket=self.markerContainer, idx=0) 197 self._SetLabelOffset() 198 else: 199 self.label.SetOrder(0) 200 201 def GetBracketLabelText(self): 202 return self.GetLabelText() 203 204 def _SetLabelOffset(self): 205 self.label.x_offset = 26 206 self.label.y_offset = 2 207 208 def SetIconColor(self, color = None): 209 self.iconColor = color 210 if self.isLoaded and getattr(self, 'pin_icon', None): 211 self.pin_icon.SetRGBA(*color) 212 213 def _ShowRenderObject(self, opacity): 214 if getattr(self, 'pin_cont', None): 215 self.pin_cont.opacity = opacity 216 self.pin_cont.Show() 217 super(MarkerPinBase, self)._ShowRenderObject(opacity) 218 219 def _HideRenderObject(self): 220 if getattr(self, 'pin_cont', None): 221 self.pin_cont.Hide() 222 super(MarkerPinBase, self)._HideRenderObject()