mapMarkerBase_Icon.py (10259B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\markers\mapMarkerBase_Icon.py 2 from carbon.common.script.util.format import FmtDist 3 from carbonui.primitives.base import ScaleDpi 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.frame import Frame 6 from carbonui.primitives.sprite import Sprite 7 import eve.client.script.ui.shared.mapView.mapViewConst as mapViewConst 8 from carbonui.uianimations import animations 9 from eve.client.script.ui.shared.mapView.mapViewUtil import MapPosToSolarSystemPos 10 from eve.client.script.ui.shared.mapView.markers.mapMarkerBase import MarkerSolarSystemBased 11 from eve.client.script.ui.inflight.bracket import BracketShadowLabel 12 import carbonui.const as uiconst 13 import geo2 14 from eve.client.script.ui.shared.mapView.markers.mapMarkerTooltip import MarkerTooltipRowBase, MarkerTooltipWrapperBase 15 from carbonui.uicore import uicore 16 17 class MarkerIconBase(MarkerSolarSystemBased): 18 tooltipRowClass = MarkerTooltipRowBase 19 label = None 20 highlightFrame = None 21 texturePath = None 22 iconColor = (1, 1, 1, 1) 23 backgroundTexturePath = 'res:/UI/Texture/classes/MapView/tagBackground.png' 24 backgroundColor = None 25 width = 14 26 height = 14 27 clientBall = None 28 pin_width = 18 29 pin_height = 24 30 overlapStackContainer = None 31 overlapMarkers = None 32 overlapEnabled = True 33 overlapSortValue = None 34 distanceSortEnabled = True 35 inRangeIndicator = None 36 distanceFadeAlphaNearFar = (0.0, mapViewConst.MAX_MARKER_DISTANCE) 37 trackingTransforms = None 38 39 def __init__(self, *args, **kwds): 40 self.highlightOnLoad = kwds.get('highlightOnLoad', False) 41 MarkerSolarSystemBased.__init__(self, *args, **kwds) 42 self.texturePath = kwds.get('texturePath', self.texturePath) 43 self.projectBracket.offsetY = -ScaleDpi(30) 44 45 def Load(self): 46 if self.isLoaded: 47 return 48 self.isLoaded = True 49 self.iconSprite = Sprite(parent=self.markerContainer, texturePath=self.texturePath, pos=((self.width - 16) / 2, 50 (self.height - 16) / 2, 51 16, 52 16), state=uiconst.UI_DISABLED, color=self.iconColor) 53 self.backgroundSprite = Sprite(parent=self.markerContainer, texturePath=self.backgroundTexturePath, pos=((self.width - 64) / 2, 54 (self.height - 64) / 2 + 12, 55 64, 56 64), state=uiconst.UI_DISABLED, color=self.backgroundColor) 57 self.markerContainer.pos = (0, 58 0, 59 self.width, 60 self.height) 61 if self.highlightOnLoad and not self.updated: 62 self.highlightOnLoad = False 63 self.HighlightLoad() 64 self.UpdateInRangeIndicatorState() 65 self.markerContainer.tooltipPanelClassInfo = MarkerTooltipWrapperBase() 66 67 def SetIconColor(self, color = None): 68 self.iconColor = color 69 if self.isLoaded: 70 self.iconSprite.SetRGBA(*color) 71 72 def DestroyRenderObject(self): 73 MarkerSolarSystemBased.DestroyRenderObject(self) 74 if self.label and not self.label.destroyed: 75 self.label.Close() 76 self.label = None 77 78 def CreateClientBall(self): 79 ballpark = sm.GetService('michelle').GetBallpark() 80 if ballpark: 81 ball = ballpark.AddClientSideBall(MapPosToSolarSystemPos(self.mapPositionLocal), isGlobal=True) 82 self.clientBall = ball 83 84 def RegisterTrackingTransform(self, transform): 85 if self.trackingTransforms is None: 86 self.trackingTransforms = [] 87 if transform not in self.trackingTransforms: 88 self.trackingTransforms.append(transform) 89 transform.translation = self.position 90 91 def UnregisterTrackingTransform(self, transform): 92 if transform in self.trackingTransforms: 93 self.trackingTransforms.remove(transform) 94 95 def Close(self, *args): 96 MarkerSolarSystemBased.Close(self, *args) 97 ballpark = sm.GetService('michelle').GetBallpark() 98 if ballpark and self.clientBall and self.clientBall.id in ballpark.balls: 99 ballpark.RemoveClientSideBall(self.clientBall.id) 100 self.clientBall = None 101 self.trackingTransforms = None 102 103 def SetInRangeIndicatorState(self, visibleState): 104 self.inRangeIndicatorState = visibleState 105 if self.isLoaded: 106 self.UpdateInRangeIndicatorState() 107 108 def UpdateInRangeIndicatorState(self): 109 if self.inRangeIndicatorState: 110 pass 111 elif self.inRangeIndicator and not self.inRangeIndicator.destroyed: 112 self.inRangeIndicator.Close() 113 self.inRangeIndicator = None 114 115 def UpdateSolarSystemPosition(self, solarSystemPosition): 116 self.mapPositionSolarSystem = solarSystemPosition 117 self.position = geo2.Vec3Add(solarSystemPosition, self.mapPositionLocal) 118 self.projectBracket.trackPosition = self.position 119 if self.trackingTransforms: 120 for each in self.trackingTransforms: 121 each.translation = self.position 122 123 def UpdateMapPositionLocal(self, mapPositionLocal, animate = False): 124 self.mapPositionLocal = mapPositionLocal 125 self.position = geo2.Vec3Add(self.mapPositionSolarSystem, mapPositionLocal) 126 self.SetBracketPosition(animate) 127 if self.trackingTransforms: 128 for each in self.trackingTransforms: 129 each.translation = self.position 130 131 def SetBracketPosition(self, animate = False): 132 if animate: 133 animations.MorphVector3(self.projectBracket, 'trackPosition', self.projectBracket.trackPosition, self.position, duration=0.6) 134 else: 135 self.projectBracket.trackPosition = self.position 136 137 def HighlightLoad(self): 138 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') 139 duration = 0.8 140 uicore.animations.MorphScalar(fill, 'width', startVal=16, endVal=160, duration=duration) 141 uicore.animations.MorphScalar(fill, 'height', startVal=16, endVal=160, duration=duration) 142 uicore.animations.MorphScalar(fill, 'opacity', startVal=0.5, endVal=0.0, duration=duration, callback=fill.Close) 143 144 def RegisterOverlapMarkers(self, overlapMarkers): 145 if self.overlapMarkers == overlapMarkers: 146 return 147 self.overlapMarkers = overlapMarkers 148 self.iconSprite.opacity = self.GetIconSpriteIdleOpacity() 149 self.backgroundSprite.opacity = self.GetBackgroundSpriteIdleOpacity() 150 if self.markerContainer: 151 self.markerContainer.pickState = uiconst.TR2_SPS_ON 152 amount = len(overlapMarkers) 153 if self.overlapStackContainer is None or self.overlapStackContainer.destroyed: 154 self.overlapStackContainer = Container(parent=self.markerContainer, align=uiconst.TOPLEFT, pos=((self.width - 20) / 2, 155 (self.height - 20) / 2 - 2, 156 20, 157 20)) 158 if len(self.overlapStackContainer.children) != amount: 159 self.overlapStackContainer.Flush() 160 for i in xrange(min(5, amount)): 161 Sprite(parent=self.overlapStackContainer, texturePath='res:/UI/Texture/classes/MapView/tagBackgroundStackIndicator.png', pos=(0, 162 -9 - i * 3, 163 20, 164 20), state=uiconst.UI_DISABLED, opacity=1.0 - i / 5.0) 165 166 def GetIconSpriteIdleOpacity(self): 167 return 1.0 168 169 def GetBackgroundSpriteIdleOpacity(self): 170 return 1.0 171 172 def SetOverlappedState(self, overlapState): 173 self.overlapMarkers = None 174 if self.overlapStackContainer: 175 overlapStackContainer = self.overlapStackContainer 176 self.overlapStackContainer = None 177 overlapStackContainer.Close() 178 if overlapState: 179 self.iconSprite.opacity = 0.0 180 self.backgroundSprite.opacity = 0.0 181 if self.dScanHilite: 182 self.dScanHilite.Hide() 183 if self.markerContainer: 184 self.markerContainer.pickState = uiconst.TR2_SPS_OFF 185 else: 186 self.iconSprite.opacity = self.GetIconSpriteIdleOpacity() 187 self.backgroundSprite.opacity = self.GetBackgroundSpriteIdleOpacity() 188 if self.markerContainer: 189 self.markerContainer.pickState = uiconst.TR2_SPS_ON 190 191 def GetOverlapSortValue(self, reset = False): 192 if self.overlapSortValue and not reset: 193 return self.overlapSortValue 194 self.overlapSortValue = (self.markerID[0], 0, (self.GetDisplayText() or '').lower()) 195 return self.overlapSortValue 196 197 def UpdateActiveAndHilightState(self, *args, **kwds): 198 if self.markerContainer: 199 if self.hilightState or self.activeState: 200 if self.highlightFrame is None or self.highlightFrame.destroyed: 201 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)) 202 self.highlightFrame.opacity = 0.5 if self.hilightState else 0.25 203 self.ShowLabel() 204 else: 205 if self.highlightFrame and not self.highlightFrame.destroyed: 206 self.highlightFrame.opacity = 0.0 207 if self.label: 208 self.label.Close() 209 210 def GetLabelText(self): 211 displayName = self.GetDisplayText() 212 distance = self.GetDistance() 213 if distance is not None: 214 displayName += ' ' + FmtDist(distance) 215 return displayName 216 217 def ShowLabel(self): 218 if not self.label or self.label.destroyed: 219 self.label = BracketShadowLabel(parent=self.markerContainer.parent, name='marker_label', align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL, text=self.GetBracketLabelText(), bracket=self.markerContainer, idx=0) 220 self._SetLabelOffset() 221 else: 222 self.label.SetOrder(0) 223 224 def GetBracketLabelText(self): 225 return self.GetLabelText() 226 227 def _SetLabelOffset(self): 228 self.label.x_offset = 26 229 self.label.y_offset = 2