careerPathToggleButtonGroup.py (7326B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillPlan\browser\careerPathToggleButtonGroup.py 2 from carbon.client.script.environment.AudioUtil import PlaySound 3 from carbonui import uiconst 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.fill import Fill 7 from carbonui.uianimations import animations 8 from carbonui.util.color import Color 9 from characterdata import careerpath 10 from eve.client.script.ui import eveColor 11 from eve.client.script.ui.control.eveLabel import EveCaptionLarge 12 from eve.client.script.ui.control.toggleButtonGroupButton import BaseToggleButtonGroupButton, ToggleButtonGroupButton 13 from eve.client.script.ui.shared.careerPortal import careerConst 14 from eve.client.script.ui.skillPlan.skillPlanInfoIcon import SkillPlanInfoIcon 15 from eveui import Sprite 16 from localization import GetByMessageID 17 LINE_OPACITY = 0.6 18 LINE_OPACITY_SELECTED = 1.0 19 LINE_LEFT = 80 20 LINE_LEFT_SELECTED = 92 21 22 def GetButtonName(careerPathID): 23 return 'CareerPathButton_%s' % careerpath.get_career_path_internal_name(careerPathID) 24 25 26 class SimpleCareerPathToggleButtonGroupButton(ToggleButtonGroupButton): 27 28 def ApplyAttributes(self, attributes): 29 super(SimpleCareerPathToggleButtonGroupButton, self).ApplyAttributes(attributes) 30 self.careerPathID = attributes.btnID 31 self.name = GetButtonName(self.careerPathID) 32 33 34 class CareerPathToggleButtonGroupButton(BaseToggleButtonGroupButton): 35 36 def ApplyAttributes(self, attributes): 37 super(CareerPathToggleButtonGroupButton, self).ApplyAttributes(attributes) 38 careerPathHint = attributes.careerPathHint 39 self.careerPathID = attributes.btnID 40 careerPath = careerpath.get_career_path(self.careerPathID) 41 careerName = GetByMessageID(careerPath.nameID) 42 self.name = GetButtonName(self.careerPathID) 43 iconCont = Container(parent=self, align=uiconst.CENTERTOP, pos=(0, 0, 270, 290)) 44 self.icon = Sprite(parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 80, 80), texturePath=careerConst.ICON_BY_CAREER_ID[self.careerPathID], opacity=1.0) 45 Sprite(name='fixedBG', parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 182, 162), texturePath='res:/UI/Texture/classes/skillPlan/careerPathButtons/fixedBG.png', opacity=1.0) 46 self.glowBG = Sprite(name='glowBG', parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 270, 290), texturePath='res:/UI/Texture/classes/skillPlan/careerPathButtons/glowBG.png', color=eveColor.WHITE, opacity=0.2) 47 self.hexagonBG = Sprite(name='hexagonBG', parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 140, 162), texturePath='res:/UI/Texture/classes/skillPlan/careerPathButtons/hexagonBG.png', color=eveColor.WHITE, opacity=0.1) 48 self.selectedFrame = Sprite(name='selectedFrame', parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, 0, 246, 279), texturePath='res:/UI/Texture/classes/skillPlan/careerPathButtons/selectionHighlight.png', color=eveColor.SMOKE_BLUE, opacity=0.0) 49 self.leftLine = Fill(parent=iconCont, align=uiconst.CENTER, opacity=LINE_OPACITY, pos=(-LINE_LEFT, 50 0, 51 2, 52 45)) 53 self.rightLine = Fill(parent=iconCont, align=uiconst.CENTER, opacity=LINE_OPACITY, pos=(LINE_LEFT, 54 0, 55 2, 56 45)) 57 titleCont = ContainerAutoSize(parent=self, name='titleCont', align=uiconst.CENTERBOTTOM, height=30, left=8) 58 titleLabelCont = ContainerAutoSize(parent=titleCont, name='titleLabelCont', align=uiconst.TOLEFT, height=30) 59 EveCaptionLarge(parent=titleLabelCont, name='titleLabel', align=uiconst.CENTER, state=uiconst.UI_DISABLED, text=careerName) 60 showInfoCont = ContainerAutoSize(parent=titleCont, name='showInfoCont', align=uiconst.TOLEFT, height=30, padLeft=10, padTop=1) 61 SkillPlanInfoIcon(parent=showInfoCont, name='showInfo', align=uiconst.CENTER, hint=careerPathHint) 62 63 def SetSelected(self, animate = True): 64 super(CareerPathToggleButtonGroupButton, self).SetSelected(animate) 65 duration = 0.15 66 if animate: 67 animations.FadeTo(self.selectedFrame, self.selectedFrame.opacity, 0.2, duration=duration) 68 animations.FadeTo(self.glowBG, self.glowBG.opacity, 0.8, duration=duration) 69 animations.FadeTo(self.hexagonBG, self.hexagonBG.opacity, 1.0, duration=duration) 70 animations.SpColorMorphTo(self.icon, self.icon.GetRGBA(), Color.BLACK, duration=duration) 71 animations.MorphScalar(self.leftLine, 'left', self.leftLine.left, -LINE_LEFT_SELECTED, duration=duration) 72 animations.MorphScalar(self.rightLine, 'left', self.rightLine.left, LINE_LEFT_SELECTED, duration=duration) 73 animations.FadeTo(self.leftLine, self.leftLine.opacity, LINE_OPACITY_SELECTED, duration=duration) 74 animations.FadeTo(self.rightLine, self.rightLine.opacity, LINE_OPACITY_SELECTED, duration=duration) 75 else: 76 self.selectedFrame.opacity = 0.2 77 self.glowBG.opacity = 0.8 78 self.hexagonBG.opacity = 1.0 79 self.icon.SetRGBA(*Color.BLACK) 80 self.leftLine.left = -LINE_LEFT_SELECTED 81 self.rightLine.left = LINE_LEFT_SELECTED 82 self.leftLine.opacity = LINE_OPACITY_SELECTED 83 self.rightLine.opacity = LINE_OPACITY_SELECTED 84 85 def SetDeselected(self, animate = True): 86 super(CareerPathToggleButtonGroupButton, self).SetDeselected(animate) 87 duration = 0.15 88 if animate: 89 animations.FadeTo(self.selectedFrame, self.selectedFrame.opacity, 0.0, duration=duration) 90 animations.FadeTo(self.glowBG, self.glowBG.opacity, 0.2, duration=duration) 91 animations.FadeTo(self.hexagonBG, self.hexagonBG.opacity, 0.1, duration=duration) 92 animations.SpColorMorphTo(self.icon, self.icon.GetRGBA(), eveColor.WHITE, duration=duration) 93 animations.MorphScalar(self.leftLine, 'left', self.leftLine.left, -LINE_LEFT, duration=duration) 94 animations.MorphScalar(self.rightLine, 'left', self.rightLine.left, LINE_LEFT, duration=duration) 95 animations.FadeTo(self.leftLine, self.leftLine.opacity, LINE_OPACITY, duration=duration) 96 animations.FadeTo(self.rightLine, self.rightLine.opacity, LINE_OPACITY, duration=duration) 97 else: 98 self.selectedFrame.opacity = 0.0 99 self.glowBG.opacity = 0.2 100 self.hexagonBG.opacity = 0.1 101 self.icon.SetRGBA(*eveColor.WHITE) 102 self.leftLine.left = -LINE_LEFT 103 self.rightLine.left = LINE_LEFT 104 self.leftLine.opacity = LINE_OPACITY 105 self.rightLine.opacity = LINE_OPACITY 106 107 def OnMouseEnter(self, *args): 108 if self.isDisabled or self.IsSelected(): 109 return 110 PlaySound('skills_planner_path_hover_play') 111 animations.FadeTo(self.hexagonBG, self.hexagonBG.opacity, 0.5, duration=uiconst.TIME_ENTRY) 112 113 def OnMouseExit(self, *args): 114 if self.isDisabled or self.IsSelected(): 115 return 116 animations.FadeTo(self.hexagonBG, self.hexagonBG.opacity, 0.1, duration=uiconst.TIME_EXIT)