skillTreeBracket.py (6096B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillTree\skillTreeBracket.py 2 from carbon.client.script.environment.AudioUtil import PlaySound 3 from carbonui import TextColor, uiconst 4 from carbonui.decorative.panelUnderlay import PanelUnderlay 5 from carbonui.primitives.bracket import Bracket 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.fill import Fill 8 from carbonui.uicore import uicore 9 from eve.client.script.ui import eveColor 10 from eve.client.script.ui.control.eveLabel import EveLabelMedium 11 from eve.client.script.ui.control.skillBar.skillBar import SkillBar 12 from eve.client.script.ui.skillTree.skillTreeConst import ALL_GROUPS 13 import math 14 STEP_ANGLE = 0.4 15 STEP_Y = 1000 16 STEP_Z = 2000 17 18 class SkillTreeBracket(Bracket): 19 default_state = uiconst.UI_NORMAL 20 default_align = uiconst.TOPLEFT 21 isDragObject = True 22 default_width = 200 23 default_height = 60 24 25 def ApplyAttributes(self, attributes): 26 super(SkillTreeBracket, self).ApplyAttributes(attributes) 27 self.skillQueueService = sm.GetService('skillqueue') 28 self.skillService = sm.GetService('skills') 29 self.graphParent = None 30 self.graphChildren = [] 31 self.angle = 0.0 32 self.controller = attributes.controller 33 self.onDoubleClick = attributes.onDoubleClick 34 self.onMouseEnter = attributes.onMouseEnter 35 self.onMouseExit = attributes.onMouseExit 36 certificateID = attributes.certificateID 37 certificateLevel = attributes.certificateLevel 38 requiredLevel = self.controller.GetCertificateRequiredSkillLevel(certificateID, certificateLevel) 39 self.currGroupID = attributes.currGroupID 40 self.mainCont = Container(name='mainCont', parent=self, padding=(10, 10, 10, 2)) 41 self.ConstructLabel(requiredLevel) 42 self.skillBar = SkillBar(parent=self.mainCont, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, skillID=self.controller.typeID, requiredLevel=requiredLevel, padTop=4) 43 self.timeLabel = None 44 self.bg = Container(name='bg', bgParent=self) 45 PanelUnderlay(bgParent=self.bg, opacity=0.85) 46 Fill(bgParent=self.bg, color=eveColor.SMOKE_BLUE if self.controller.IsRoot() else eveColor.BLACK, opacity=0.05) 47 self.SetNormal() 48 49 def ConstructLabel(self, requiredLevel): 50 color = TextColor.NORMAL if self.controller.IsInjected() else TextColor.DISABLED 51 if requiredLevel: 52 text = self.controller.GetRequiredSkillNameAndLevelComparedToTrainedLevel(requiredLevel) 53 else: 54 text = '%s (%sx)' % (self.controller.GetName(), int(self.controller.GetRank())) 55 if not self.IsInCurrentGroup(): 56 text += '\n<color=red>%s</color>' % self.controller.GetCategoryAndGroupName() 57 self.label = EveLabelMedium(parent=self.mainCont, align=uiconst.TOTOP, text=text, color=color, autoFadeSides=10) 58 59 def IsInCurrentGroup(self): 60 return self.currGroupID in (ALL_GROUPS, self.controller.GetGroupID()) 61 62 def IsRoot(self): 63 if self.currGroupID == ALL_GROUPS: 64 return self.controller.IsRoot() 65 else: 66 return self.controller.IsRootOfGroup() 67 68 def GetMenu(self): 69 return self.controller.GetMenu() 70 71 def GetDragData(self): 72 return self.controller.GetDragData() 73 74 def OnMouseEnter(self, *args): 75 PlaySound(uiconst.SOUND_ENTRY_HOVER) 76 if self.onMouseEnter: 77 self.onMouseEnter(self) 78 79 def OnMouseExit(self): 80 if self.onMouseExit: 81 self.onMouseExit(self) 82 83 def OnMouseDown(self, *args): 84 super(SkillTreeBracket, self).OnMouseDown(*args) 85 uicore.uilib.tooltipHandler.CloseTooltip() 86 87 def OnDblClick(self): 88 sm.GetService('info').ShowInfo(self.controller.GetTypeID()) 89 90 def SetNormal(self): 91 if self.IsRoot() and self.currGroupID != ALL_GROUPS: 92 self.width = 200 93 self.height = 60 94 else: 95 self.width = self.height = 20 96 self.bg.opacity = 1.0 97 98 def SetEmphasized(self): 99 self.bg.opacity = 1.0 100 self.width = 200 101 self.height = 60 102 103 def SetDeemphasized(self): 104 self.bg.opacity = 0.1 105 self.width = self.height = 20 106 107 def AddToGraph(self, graphParent, i, j, k): 108 self.graphParent = graphParent 109 if graphParent: 110 graphParent.graphChildren.append(self) 111 self.graphPos = (i, j, k) 112 113 def SetRadialPos(self, radius, angle): 114 self.radius = radius 115 self.angle = angle 116 117 def GetXYZ(self): 118 _, j, k = self.graphPos 119 self.angle = self._GetAngle(k) 120 parX, _, parZ = self.GetParXYZPosition() 121 x = parX + STEP_Z * math.cos(self.angle) 122 y = j * STEP_Y 123 z = parZ + STEP_Z * math.sin(self.angle) 124 return (x, y, z) 125 126 def _GetAngle(self, k): 127 angle = self.GetBaseAngle() 128 numSiblings = len(self.GetSiblings()) 129 i = self.GetSiblings().index(self) 130 if numSiblings == 1: 131 pass 132 elif k == 1: 133 angleStep = 2 * math.pi / numSiblings 134 angle += i * angleStep 135 else: 136 angleStep = math.pi / 2 / (numSiblings - 1) 137 angle += (i - (numSiblings - 1) / 2.0) * angleStep 138 return angle 139 140 def GetParXYZPosition(self): 141 if self.graphParent: 142 return self.graphParent.GetXYZPosition() 143 else: 144 return (0, 0, 0) 145 146 def GetXYZPosition(self): 147 return self.projectBracket.trackPosition 148 149 def GetBaseAngle(self): 150 if self.graphParent: 151 return self.graphParent.angle 152 else: 153 return 0.0 154 155 def UpdateBracketPosition(self): 156 self.projectBracket.trackPosition = self.GetXYZ() 157 for graphChild in self.graphChildren: 158 graphChild.UpdateBracketPosition() 159 160 def GetSiblings(self): 161 if self.graphParent: 162 return self.graphParent.graphChildren 163 else: 164 return [self] 165 166 def GetHint(self): 167 return repr(self.graphPos)