careerView.py (13705B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\careerPortal\circleView\careerView.py 2 import math 3 import eve.client.script.ui.shared.careerPortal.careerConst as careerConst 4 import eveicon 5 from carbon.client.script.environment.AudioUtil import PlaySound 6 from carbonui import TextAlign, uiconst 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.containerAutoSize import ContainerAutoSize 9 from carbonui.uianimations import animations 10 from characterdata import careerpathconst 11 from eve.client.script.ui import eveColor 12 from eve.client.script.ui.control.eveLabel import EveCaptionLarge 13 from eve.client.script.ui.shared.careerPortal import cpSignals 14 from eve.client.script.ui.shared.careerPortal.careerPointsLabel import CareerPointsLabel 15 from eve.client.script.ui.shared.careerPortal.circleView.careerNode import CareerNode, CareerNodeObject, NODE_MAX_SIZE 16 from eve.client.script.ui.shared.careerPortal.circleView.circleView import CircleView, CircleViewContainer 17 from eveui import Sprite 18 from localization import GetByLabel 19 CIRCLE_HOVER_OPACITY = 1.0 20 CENTRAL_ICON_BASE_WIDTH = 516 21 CENTRAL_ICON_BASE_HEIGHT = 360 22 SMALL_FONTSIZE = 18 23 24 class CareerView(CircleViewContainer): 25 default_name = 'CareerView' 26 default_opacity = 1 27 activityViewCareerInfoTop = 0.67 28 goalViewCareerInfoTop = 0.7 29 30 def __init__(self, *args, **kwargs): 31 self.careerInfoTop = 0.5 32 super(CareerView, self).__init__(*args, **kwargs) 33 self.circleView.OnCareerWindowStateChanged(self.initialState) 34 35 def CreateCircleView(self, *args, **kwargs): 36 return CareerCircleView(parent=self, *args, **kwargs) 37 38 def GetSignals(self): 39 signals = super(CareerView, self).GetSignals() 40 signals.extend([(careerConst.CAREER_WINDOW_STATE_SETTING.on_change, self.OnCareerWindowStateChanged), (cpSignals.on_career_node_hover_on, self.OnCareerNodeHoverOn), (cpSignals.on_career_node_hover_off, self.OnCareerNodeHoverOff)]) 41 return signals 42 43 def on_parent_window_end_resize(self, wnd): 44 super(CareerView, self).on_parent_window_end_resize(wnd) 45 w, _ = wnd.GetAbsoluteSize() 46 if w < 1200: 47 self.careerNameLabel.fontsize = SMALL_FONTSIZE 48 self.activityNameLabel.fontsize = SMALL_FONTSIZE 49 self.backLabel.fontsize = SMALL_FONTSIZE 50 else: 51 self.careerNameLabel.fontsize = self.careerNameLabel.default_fontsize 52 self.activityNameLabel.fontsize = self.activityNameLabel.default_fontsize 53 self.backLabel.fontsize = self.backLabel.default_fontsize 54 self._UpdateCareerInfoTop() 55 56 def OnCareerWindowStateChanged(self, newState, animate = True): 57 selectedCareer = careerConst.SELECTED_CAREER_PATH_SETTING.get() 58 careerNode = self.nodesByID.get(selectedCareer, None) 59 if newState == careerConst.CareerWindowState.CAREERS_VIEW: 60 self._GoToCareerViewState() 61 animations.FadeOut(self.backLabelCont, duration=0.4, callback=self.backLabelCont.Hide) 62 return 63 if careerNode: 64 self.careerPointsLabel.careerNodeObject = careerNode.nodeObject 65 self.careerNameLabel.text = careerConst.GetCareerPathName(selectedCareer) 66 if newState == careerConst.CareerWindowState.ACTIVITIES_VIEW: 67 if not careerNode: 68 return 69 self.backLabel.text = GetByLabel('UI/CareerPortal/GoToCareerOverview') 70 self._GoToActivityViewState(careerNode, animate) 71 elif newState == careerConst.CareerWindowState.GOALS_VIEW: 72 self.backLabel.text = GetByLabel('UI/CareerPortal/GoToActivities') 73 self._GoToGoalViewState(animate, selectedCareer) 74 else: 75 return 76 77 def _GoToCareerViewState(self): 78 animations.FadeOut(self.careerInfoContainer, duration=0.2) 79 80 def _GoToGoalViewState(self, animate, selectedCareer): 81 selectedActivity = careerConst.SELECTED_ACTIVITY_SETTING.get() 82 activityName = careerConst.GetCareerPathGroupName(selectedCareer, selectedActivity) 83 self.careerNameLabel.bold = False 84 self.activityNameLabel.text = activityName 85 self._UpdateCareerInfoTop() 86 if animate: 87 if self.backLabelCont.IsHidden(): 88 self._UpdateCareerInfoContainer() 89 animations.MorphScalar(self.activityNameLabel, 'top', startVal=self.activityNameLabel.top, endVal=0, duration=0.5) 90 animations.FadeIn(self.activityNameLabel, duration=0.75) 91 else: 92 self.careerInfoContainer.opacity = 1 93 self.activityNameLabel.top = 0 94 self.activityNameLabel.opacity = 1 95 96 def _UpdateCareerInfoContainer(self): 97 self._UpdateCareerInfoTop() 98 animations.MorphScalar(self.careerInfoContainer, 'top', startVal=self.careerInfoContainer.top, endVal=self.careerInfoTop, duration=0.5) 99 animations.FadeIn(self.careerInfoContainer, duration=1.0) 100 101 def _UpdateCareerInfoTop(self): 102 windowState = careerConst.CAREER_WINDOW_STATE_SETTING.get() 103 if windowState == careerConst.CareerWindowState.ACTIVITIES_VIEW: 104 self.careerInfoTop = self.activityViewCareerInfoTop 105 elif windowState == careerConst.CareerWindowState.GOALS_VIEW: 106 self.careerInfoTop = self.goalViewCareerInfoTop 107 108 def _GoToActivityViewState(self, careerNode, animate): 109 self.careerNameLabel.bold = True 110 self.careerNameLabel.text = careerNode.nodeObject.careerPathName 111 self._UpdateCareerInfoTop() 112 if animate: 113 if self.backLabelCont.IsHidden(): 114 self._UpdateCareerInfoContainer() 115 animations.MorphScalar(self.activityNameLabel, 'top', startVal=self.activityNameLabel.top, endVal=-30, duration=0.5) 116 animations.FadeOut(self.activityNameLabel, duration=0.5) 117 else: 118 self.careerInfoContainer.top = 0.61 119 self.activityNameLabel.top = -30 120 self.activityNameLabel.opacity = 0 121 self.careerInfoContainer.opacity = 1 122 123 def OnCareerNodeHoverOn(self, *args): 124 currentState = careerConst.CAREER_WINDOW_STATE_SETTING.get() 125 if currentState == careerConst.CareerWindowState.CAREERS_VIEW: 126 return 127 self._ShowBackLabel() 128 129 def OnCareerNodeHoverOff(self, *args): 130 currentState = careerConst.CAREER_WINDOW_STATE_SETTING.get() 131 if currentState == careerConst.CareerWindowState.CAREERS_VIEW: 132 return 133 self._HideBackLabel() 134 135 def _ShowBackLabel(self): 136 animations.MorphScalar(self.careerInfoContainer, 'top', startVal=self.careerInfoContainer.top, endVal=self.careerInfoTop - 0.05, duration=0.4) 137 animations.FadeOut(self.careerInfoContainer, duration=0.4) 138 animations.MorphScalar(self.backLabelCont, 'top', startVal=self.backLabelCont.top, endVal=0.65, duration=0.4) 139 animations.FadeIn(self.backLabelCont, duration=0.4) 140 self.backLabelCont.Show() 141 142 def _HideBackLabel(self): 143 animations.MorphScalar(self.careerInfoContainer, 'top', startVal=self.careerInfoContainer.top, endVal=self.careerInfoTop, duration=0.4) 144 animations.FadeIn(self.careerInfoContainer, duration=0.4) 145 animations.MorphScalar(self.backLabelCont, 'top', startVal=self.backLabelCont.top, endVal=0.725, duration=0.4) 146 animations.FadeOut(self.backLabelCont, duration=0.4, callback=self.backLabelCont.Hide) 147 148 def PrepareUI(self): 149 super(CareerView, self).PrepareUI() 150 self.careerInfoContainer = ContainerAutoSize(name='careerInfoContainer', parent=self, align=uiconst.TOPLEFT_PROP, left=0.5, top=0.67, state=uiconst.UI_DISABLED, width=CENTRAL_ICON_BASE_WIDTH, opacity=0) 151 self.careerNameLabel = EveCaptionLarge(name='careerNameLabel', parent=self.careerInfoContainer, textAlign=TextAlign.CENTER, align=uiconst.TOTOP, bold=True) 152 self.activityNameLabel = EveCaptionLarge(name='activityNameLabel', parent=self.careerInfoContainer, textAlign=TextAlign.CENTER, align=uiconst.TOTOP, opacity=0, maxWidth=100, bold=True, text='---', top=-30) 153 pointsContainer = Container(name='pointsContainer', parent=self.careerInfoContainer, align=uiconst.TOTOP, height=20) 154 self.careerPointsLabel = CareerPointsLabel(parent=pointsContainer, careerNode=None, top=4) 155 self.backLabelCont = ContainerAutoSize(name='backLabelCont', parent=self, align=uiconst.TOPLEFT_PROP, left=0.5, top=0.67, height=30, opacity=0) 156 self.backLabelCont.Hide() 157 Sprite(name='leftArrow', parent=Container(parent=self.backLabelCont, align=uiconst.TOLEFT, width=16, height=16), align=uiconst.CENTER, pos=(0, 0, 16, 16), texturePath=eveicon.chevron_left) 158 self.backLabel = EveCaptionLarge(parent=ContainerAutoSize(parent=self.backLabelCont, align=uiconst.TOLEFT), name='backLabel', align=uiconst.CENTERLEFT, left=4, text='placeholder', state=uiconst.UI_DISABLED, bold=True) 159 self._CreateCareerNodes() 160 161 def _CreateCareerNodes(self): 162 for idx, careerPathID in enumerate(careerConst.GetSortedCareerPaths()): 163 nodeObject = CareerNodeObject(careerPathID) 164 node = CareerNode(name='careerNode_%s' % careerPathID, nodeObject=nodeObject, initialState=self.initialState) 165 self.circleView.AddNode(node) 166 self.nodesByID[careerPathID] = node 167 168 self.circleView.UpdateCircle() 169 170 171 class CareerCircleView(CircleView): 172 default_arc_opacity = 1.0 173 innerCircleTexturePath = 'res:/UI/Texture/classes/careerPortal/career_hover_inner_2px.png' 174 175 def ApplyAttributes(self, attributes): 176 super(CareerCircleView, self).ApplyAttributes(attributes) 177 careerConst.CAREER_WINDOW_STATE_SETTING.on_change.connect(self.OnCareerWindowStateChanged) 178 cpSignals.on_career_node_hover_on.connect(self.OnCareerNodeHoverOn) 179 cpSignals.on_career_node_hover_off.connect(self.OnCareerNodeHoverOff) 180 self.innerCircles.opacity = 0 181 self.fill.opacity = 0 182 183 def _GetViewColor(self): 184 return eveColor.Color(eveColor.WHITE).SetOpacity(0.4).GetRGBA() 185 186 def ConstructInnerCircles(self): 187 super(CareerCircleView, self).ConstructInnerCircles() 188 self.innerCircles.outputMode = uiconst.OUTPUT_COLOR_AND_GLOW 189 190 def _GetInnerCircleScale(self): 191 return (0.8, 0.8) 192 193 def _GetNodeMask(self): 194 selectedCareerPath = careerConst.SELECTED_CAREER_PATH_SETTING.get() 195 if selectedCareerPath in (careerpathconst.career_path_enforcer, careerpathconst.career_path_explorer): 196 return 'res:/UI/Texture/classes/careerPortal/nodeMasks/career_inner_mask_down.png' 197 else: 198 return 'res:/UI/Texture/classes/careerPortal/nodeMasks/career_inner_mask_up.png' 199 200 def Close(self): 201 careerConst.CAREER_WINDOW_STATE_SETTING.on_change.disconnect(self.OnCareerWindowStateChanged) 202 cpSignals.on_career_node_hover_on.disconnect(self.OnCareerNodeHoverOn) 203 cpSignals.on_career_node_hover_off.disconnect(self.OnCareerNodeHoverOff) 204 super(CircleView, self).Close() 205 206 def GetNodeSize(self): 207 return min(NODE_MAX_SIZE, self.width * 0.215) 208 209 def _GetAngleOffset(self): 210 return -math.pi / 4 211 212 def OnCareerNodeHoverOn(self, *args): 213 if careerConst.CAREER_WINDOW_STATE_SETTING.get() != careerConst.CareerWindowState.ACTIVITIES_VIEW: 214 return 215 PlaySound('career_portal_go_to_activities_play') 216 animations.FadeIn(self.innerCircles, endVal=0.4, duration=0.4) 217 218 def OnCareerNodeHoverOff(self, *args): 219 if careerConst.CAREER_WINDOW_STATE_SETTING.get() != careerConst.CareerWindowState.ACTIVITIES_VIEW: 220 return 221 animations.FadeOut(self.innerCircles, duration=0.4) 222 223 def OnCareerWindowStateChanged(self, state, animate = True): 224 careerID = careerConst.SELECTED_CAREER_PATH_SETTING.get() 225 if animate: 226 animations.FadeOut(self.innerCircles, duration=0.4) 227 else: 228 self.innerCircles.opacity = 0 229 self.innerCircles.SetSecondaryTexturePath(self._GetNodeMask()) 230 if state in (careerConst.CareerWindowState.ACTIVITIES_VIEW, careerConst.CareerWindowState.GOALS_VIEW): 231 self._GoToAlternateState(animate, careerID) 232 elif state == careerConst.CareerWindowState.CAREERS_VIEW: 233 self._GoToCareerState(animate) 234 else: 235 return 236 237 def _GoToCareerState(self, animate): 238 if animate: 239 animations.FadeIn(self.outerCircle, endVal=0.4, duration=0.5) 240 animations.Tr2DScaleTo(self, startScale=self.scale, endScale=(1.0, 1.0)) 241 animations.Tr2DRotateTo(self, startAngle=self.rotation, endAngle=0) 242 else: 243 self.outerCircle.opacity = 0.4 244 self.scale = (1, 1) 245 self.rotation = 0 246 247 def _GoToAlternateState(self, animate, careerID): 248 if animate: 249 animations.FadeOut(self.outerCircle, duration=0.5) 250 animations.Tr2DScaleTo(self, startScale=self.scale, endScale=(0.6, 0.6)) 251 animations.Tr2DRotateTo(self, startAngle=self.rotation, endAngle=math.radians(careerConst.CIRCLE_ROTATION_BY_CAREER[careerID])) 252 animations.SpSecondaryTextureRotate(self.innerCircles, startVal=self.rotation, endVal=-math.radians(careerConst.CIRCLE_ROTATION_BY_CAREER[careerID]), duration=0.5) 253 else: 254 if self.outerCircle: 255 self.outerCircle.opacity = 0 256 self.scale = (0.6, 0.6) 257 self.rotation = math.radians(careerConst.CIRCLE_ROTATION_BY_CAREER[careerID]) 258 self.innerCircles.rotationSecondary = -math.radians(careerConst.CIRCLE_ROTATION_BY_CAREER[careerID])