overviewNodeUtil.py (4815B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\overview\overviewNodeUtil.py 2 import re 3 import telemetry 4 import geo2 5 import blue 6 from eve.client.script.ui.inflight.bracketsAndTargets.bracketVarious import GetIconColor 7 from eve.client.script.ui.inflight.overview.overviewConst import HTML_ENTITIES, HTML_ENTITY_REPLACEMENTS, COLUMN_CORPORATION, COLUMN_ALLIANCE 8 from eve.client.script.ui.inflight.overview.overviewUtil import GetCorpTickerName, GetAllianceTickerName, PrepareLocalizationTooltip 9 from eve.client.script.ui.shared.stateFlag import GetIconFlagAndBackgroundFlag 10 from eve.client.script.ui.util import uix 11 from eve.common.lib import appConst as const 12 13 def _Encode(text): 14 return re.sub(HTML_ENTITIES, lambda match: HTML_ENTITY_REPLACEMENTS[match.group()], text) 15 16 17 def PrimeDisplayName(node): 18 slimItem = node.slimItem() 19 if not slimItem: 20 return 21 name = uix.GetSlimItemName(slimItem) 22 if slimItem.groupID == const.groupStation: 23 name = uix.EditStationName(name, usename=0) 24 if node.usingLocalizationTooltips: 25 name, hint = PrepareLocalizationTooltip(name) 26 node.hint_NAME = hint 27 node.display_NAME = _Encode(name) 28 if node.sortNameIndex is not None: 29 node.sortValue[node.sortNameIndex] = name.lower() 30 node.hint_NAME = sm.GetService('bracket').GetDisplayNameForBracket(slimItem) 31 32 33 @telemetry.ZONE_METHOD 34 def UpdateIconAndBackgroundFlagsOnNode(node): 35 slimItem = node.slimItem() 36 if slimItem is None: 37 return 38 iconFlag, backgroundFlag = (0, 0) 39 if node.updateItem: 40 iconFlag, backgroundFlag = GetIconFlagAndBackgroundFlag(slimItem) 41 node.iconAndBackgroundFlags = (iconFlag, backgroundFlag) 42 if node.sortIconIndex is not None: 43 iconFlag, backgroundFlag = node.iconAndBackgroundFlags 44 node.iconColor, colorSortValue = GetIconColor(slimItem, getSortValue=True) 45 node.sortValue[node.sortIconIndex] = [iconFlag, 46 colorSortValue, 47 backgroundFlag, 48 slimItem.categoryID, 49 slimItem.groupID, 50 slimItem.typeID] 51 if node.panel: 52 node.panel.UpdateFlagAndBackground(slimItem) 53 54 55 def PrimeCorpAndAllianceName(node, columnSettings): 56 slimItem = node.slimItem() 57 if not slimItem: 58 return 59 if slimItem.categoryID != const.categoryShip: 60 return 61 showCorporation, sortCorporationIndex = columnSettings[COLUMN_CORPORATION] 62 if showCorporation: 63 if slimItem.corpID: 64 corpTag = GetCorpTickerName(slimItem) 65 else: 66 corpTag = '' 67 node.display_CORPORATION = corpTag 68 if sortCorporationIndex is not None: 69 node.sortValue[sortCorporationIndex] = corpTag.lower() 70 showAlliance, sortAllianceIndex = columnSettings[COLUMN_ALLIANCE] 71 if showAlliance: 72 if slimItem.allianceID: 73 alliance = GetAllianceTickerName(slimItem) 74 else: 75 alliance = '' 76 node.display_ALLIANCE = alliance 77 if sortAllianceIndex is not None: 78 node.sortValue[sortAllianceIndex] = alliance.lower() 79 80 81 @telemetry.ZONE_METHOD 82 def UpdateVelocityData(node, ball, myBall, calculateVelocity, calculateRadialVelocity, calculateCombinedVelocity, calculateRadialNormal, calculateTransveralVelocity, calculateAngularVelocity): 83 surfaceDist = max(ball.surfaceDist, 0) 84 velocity = None 85 radialVelocity = None 86 angularVelocity = None 87 transveralVelocity = None 88 if calculateCombinedVelocity: 89 CombVel4 = (ball.vx - myBall.vx, ball.vy - myBall.vy, ball.vz - myBall.vz) 90 if calculateRadialNormal: 91 RadNorm4 = geo2.Vec3Normalize((ball.x - myBall.x, ball.y - myBall.y, ball.z - myBall.z)) 92 if calculateVelocity: 93 velocity = ball.GetVectorDotAt(blue.os.GetSimTime()).Length() 94 if calculateRadialVelocity: 95 radialVelocity = geo2.Vec3Dot(CombVel4, RadNorm4) 96 if calculateTransveralVelocity: 97 transveralVelocity = geo2.Vec3Length(geo2.Vec3Subtract(CombVel4, geo2.Vec3Scale(RadNorm4, radialVelocity))) 98 if calculateAngularVelocity: 99 angularVelocity = transveralVelocity / max(1.0, surfaceDist) 100 node.rawVelocity = velocity 101 node.rawRadialVelocity = radialVelocity 102 node.rawAngularVelocity = angularVelocity 103 node.rawTransveralVelocity = transveralVelocity 104 if node.sortVelocityIndex is not None: 105 node.sortValue[node.sortVelocityIndex] = velocity 106 if node.sortRadialVelocityIndex is not None: 107 node.sortValue[node.sortRadialVelocityIndex] = radialVelocity 108 if node.sortAngularVelocityIndex is not None: 109 node.sortValue[node.sortAngularVelocityIndex] = angularVelocity 110 if node.sortTransversalVelocityIndex is not None: 111 node.sortValue[node.sortTransversalVelocityIndex] = transveralVelocity