goalDetailsPanel.py (13388B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\careerPortal\panels\goalDetailsPanel.py 2 import eveicon 3 import evetypes 4 from carbon.client.script.environment.AudioUtil import PlaySound 5 from carbon.common.script.util import logUtil as log 6 from carbon.common.script.util.format import FmtAmt 7 from carbonui import Axis, ButtonFrameType, ButtonVariant, uiconst 8 from carbonui.button.group import ButtonGroup, ButtonSizeMode 9 from carbonui.control.button import Button 10 from carbonui.primitives.container import Container 11 from carbonui.primitives.containerAutoSize import ContainerAutoSize 12 from carbonui.primitives.line import Line 13 from carbonui.primitives.sprite import Sprite 14 from carbonui.uianimations import animations 15 from careergoals.client.goal import Goal 16 from careergoals.client.signal import on_goal_completed, on_definitions_loaded 17 from eve.client.script.ui import eveColor 18 from eve.client.script.ui.control.eveLabel import EveCaptionSmall, EveLabelMedium, EveCaptionLarge, EveLabelLarge 19 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel 20 from eve.client.script.ui.control.glowSprite import GlowSprite 21 from eve.client.script.ui.shared.agencyNew.contentGroups.contentGroupConst import contentGroupHome 22 from eve.client.script.ui.shared.agencyNew.ui.agencyWnd import AgencyWndNew 23 from eve.client.script.ui.shared.careerPortal import careerConst, cpSignals 24 from eve.client.script.ui.shared.careerPortal.careerConst import AGENCY_SECTION_NAMES_TO_IDS 25 from eve.client.script.ui.shared.careerPortal.careerControllerUI import get_career_portal_controller_svc 26 from eve.client.script.ui.shared.careerPortal.panels.basePanel import BasePanel 27 from eve.client.script.ui.shared.careerPortal.panels.detailsEntry import OmegaRewardDetailsEntry, AlphaRewardDetailsEntry, CareerPointsDetailsEntry, GoalInfoDetailsEntry 28 from eve.client.script.ui.shared.careerPortal.util import OpenFreelanceProjects, are_freelance_projects_available 29 from eve.client.script.ui.shared.careerPortal.util import get_text_for_reward 30 from fsdBuiltData.client.agency.helpVideoFSDLoader import AgencyHelpVideosFSDLoader 31 from localization import GetByLabel, GetByMessageID 32 MAX_LABEL_WIDTH = 250 33 BOTTOM_CONT_HEIGHT = 32 34 COMPLETION_FADE_IN_DURATION = 0.1 35 36 class AuraGoalPanel(BasePanel): 37 default_state = uiconst.UI_NORMAL 38 default_name = 'AuraGoalAssistanceSection' 39 40 def ApplyAttributes(self, attributes): 41 super(AuraGoalPanel, self).ApplyAttributes(attributes) 42 self.ConstructHeader() 43 self.ConstructEmptyBody() 44 if are_freelance_projects_available(): 45 Line(parent=self, align=uiconst.TOTOP, top=16) 46 self._ConstructFreelanceJobSection() 47 48 def LoadGoal(self, goal): 49 if self.mainCont.destroyed: 50 return 51 self.bodyCont.Flush() 52 PlaySound('career_portal_aura_assistance_play') 53 EveLabelLarge(parent=self.bodyCont, state=uiconst.UI_NORMAL, align=uiconst.TOTOP, text=GetByMessageID(int(goal.definition.aura_text_id)), padBottom=16) 54 buttonCont = ButtonGroup(parent=self.bodyCont, align=uiconst.TOTOP, orientation=Axis.VERTICAL, button_size_mode=ButtonSizeMode.STRETCH) 55 if goal.definition.has_video_id(): 56 video = AgencyHelpVideosFSDLoader.GetByID(int(goal.definition.video_id)) 57 if video: 58 self.videoButton = Button(name='videoButton', parent=buttonCont, label=GetByMessageID(video.nameID), texturePath='res:/UI/Texture/classes/careerPortal/playVideo.png', func=lambda x: get_career_portal_controller_svc().play_video(video.path), variant=ButtonVariant.GHOST) 59 agencyLinkIdString = goal.definition.agency_link_text_id 60 if agencyLinkIdString and agencyLinkIdString != u'null': 61 if goal.definition.agency_screen_id in AGENCY_SECTION_NAMES_TO_IDS: 62 agencyContentGroup = AGENCY_SECTION_NAMES_TO_IDS[goal.definition.agency_screen_id] 63 else: 64 agencyContentGroup = contentGroupHome 65 log.LogWarn('Failed to find %s in AGENCY_SECTION_NAMES_TO_IDS - Defaulting to agency homepage' % goal.definition.agency_screen_id) 66 67 def open_career_agents_in_agency(): 68 PlaySound('career_portal_career_agents_play') 69 AgencyWndNew.OpenAndShowContentGroup(agencyContentGroup) 70 71 self.showInAgencyBtn = Button(parent=buttonCont, label=GetByMessageID(int(agencyLinkIdString)), texturePath='res:/UI/Texture/classes/careerPortal/aura_icon_agency.png', func=open_career_agents_in_agency, args=(), variant=ButtonVariant.GHOST) 72 73 def ConstructEmptyBody(self): 74 self.bodyCont = ContainerAutoSize(padLeft=5, parent=self, align=uiconst.TOTOP, alignMode=uiconst.TOTOP) 75 76 def ConstructHeader(self): 77 self.headerCont = Container(parent=self, align=uiconst.TOTOP, height=32, padBottom=5) 78 Sprite(parent=self.headerCont, align=uiconst.TOLEFT, useSizeFromTexture=True, texturePath='res:/UI/Texture/classes/careerPortal/aura/aura_icon_32x32.png', width=32) 79 EveCaptionLarge(parent=self.headerCont, align=uiconst.TOLEFT, text=GetByLabel('UI/CareerPortal/AuraAssistancePanelTitle'), padLeft=8, color=eveColor.AURA_PURPLE, bold=True) 80 81 def _ConstructFreelanceJobSection(self): 82 EveCaptionSmall(name='freelanceJobsTitle', parent=self, align=uiconst.TOTOP, text=GetByLabel('UI/CareerPortal/AuraAssistanceFreelanceJobsTitle'), bold=True, top=16) 83 buttonCont = ButtonGroup(parent=self, align=uiconst.TOTOP, orientation=Axis.VERTICAL, button_size_mode=ButtonSizeMode.STRETCH, top=16) 84 Button(parent=buttonCont, label=GetByLabel('UI/CareerPortal/OpenFreelanceJobs'), texturePath=eveicon.freelance_projects, func=OpenFreelanceProjects, args=(), variant=ButtonVariant.GHOST) 85 86 87 class GoalPanel(BasePanel): 88 default_name = 'GoalPanel' 89 90 def ApplyAttributes(self, attributes): 91 super(GoalPanel, self).ApplyAttributes(attributes) 92 self.goal = None 93 self.ConstructHeaderSubsection() 94 self.ConstructRewardsSubsection() 95 self.ConstructInformationSubsection() 96 self.ConstructBottomSubsection() 97 self._ConnectSignals() 98 99 def Close(self): 100 self._DisconnectSignals() 101 super(GoalPanel, self).Close() 102 103 def _ConnectSignals(self): 104 cpSignals.on_cp_goal_tracking_added.connect(self.OnGoalTrackingAdded) 105 cpSignals.on_cp_goal_tracking_removed.connect(self.OnGoalTrackingRemoved) 106 on_goal_completed.connect(self.OnGoalCompleted) 107 on_definitions_loaded.connect(self._LoadRewards) 108 109 def _DisconnectSignals(self): 110 cpSignals.on_cp_goal_tracking_added.disconnect(self.OnGoalTrackingAdded) 111 cpSignals.on_cp_goal_tracking_removed.disconnect(self.OnGoalTrackingRemoved) 112 on_goal_completed.disconnect(self.OnGoalCompleted) 113 on_definitions_loaded.disconnect(self._LoadRewards) 114 115 def LoadGoal(self, goal): 116 if self.mainCont.destroyed: 117 return 118 self.goal = goal 119 self.rewardsSubsection.Flush() 120 self.informationSubsection.Flush() 121 self.goalName.text = goal.definition.name 122 self.goalDescription.text = goal.definition.description 123 self._LoadRewards() 124 GoalInfoDetailsEntry(parent=self.informationSubsection, texture_path='res:/UI/Texture/Shared/warning_16.png', text=GetByLabel('UI/CareerPortal/Threat'), value=careerConst.get_threat_name(goal.definition.threat)) 125 GoalInfoDetailsEntry(parent=self.informationSubsection, texture_path='res:/UI/Texture/classes/careerPortal/clock_16.png', text=GetByLabel('UI/CareerPortal/GoalDuration'), value=goal.definition.duration_text) 126 if goal.is_completed(): 127 self._HideTrackedButton(animate=False) 128 self._ShowCompletedState(animate=False) 129 else: 130 self._ShowTrackedButton() 131 self._HideCompletedState() 132 self.trackButton.SetFunc(lambda x: self.OnTrackButtonPressed(goal.goal_id, x)) 133 isTracked = get_career_portal_controller_svc().is_goal_tracked(goal.goal_id) 134 if isTracked: 135 self._SetButtonToTrackedState() 136 else: 137 self._SetButtonToUntrackedState() 138 139 def _LoadRewards(self): 140 if self.rewardsSubsection.children: 141 return 142 if not self.goal: 143 return 144 for reward in self.goal.definition.omega_rewards: 145 self.create_omega_reward_entry(reward) 146 147 for reward in self.goal.definition.alpha_rewards: 148 self.create_alpha_reward_entry(reward) 149 150 self.create_career_points_entry() 151 self.rewardsLoadingWheel.Hide() 152 153 def create_omega_reward_entry(self, reward): 154 OmegaRewardDetailsEntry(parent=self.rewardsSubsection, reward=reward, text=get_text_for_reward(reward)) 155 156 def create_alpha_reward_entry(self, reward): 157 AlphaRewardDetailsEntry(parent=self.rewardsSubsection, reward=reward, text=get_text_for_reward(reward)) 158 159 def create_career_points_entry(self): 160 CareerPointsDetailsEntry(parent=self.rewardsSubsection, texture_path=careerConst.CAREERS_32_SIZES[self.goal.definition.career], text=self.goal.definition.career_points_text) 161 162 def ConstructHeaderSubsection(self): 163 self.goalName = EveCaptionLarge(parent=self.mainCont, align=uiconst.TOTOP, bold=True) 164 self.goalDescription = EveLabelMedium(parent=self.mainCont, align=uiconst.TOTOP) 165 166 def ConstructRewardsSubsection(self): 167 Line(parent=self.mainCont, align=uiconst.TOTOP, padding=(0, 8, 0, 8)) 168 EveCaptionSmall(parent=self.mainCont, align=uiconst.TOTOP, text=GetByLabel('UI/CareerPortal/RewardsHeader')) 169 self.rewardsSubsection = ContainerAutoSize(name='RewardsSubsection', parent=self.mainCont, align=uiconst.TOTOP) 170 self.rewardsLoadingWheel = LoadingWheel(name='LoadingWheel', parent=ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP), align=uiconst.CENTERTOP, width=32, height=32) 171 172 def ConstructInformationSubsection(self): 173 Line(parent=self.mainCont, align=uiconst.TOTOP, padding=(0, 8, 0, 8)) 174 EveCaptionSmall(parent=self.mainCont, align=uiconst.TOTOP, text=GetByLabel('UI/Common/Information')) 175 self.informationSubsection = ContainerAutoSize(name='InformationSubsection', parent=self.mainCont, align=uiconst.TOTOP) 176 177 def ConstructBottomSubsection(self): 178 bottomCont = Container(parent=self.mainCont, name='bottomCont', align=uiconst.TOTOP, top=16, height=BOTTOM_CONT_HEIGHT) 179 self.trackButton = Button(parent=bottomCont, name='trackButton', align=uiconst.TOTOP, iconSize=20, frame_type=ButtonFrameType.CUT_BOTTOM_LEFT_RIGHT) 180 self.completedCont = ContainerAutoSize(parent=bottomCont, name='completedCont', align=uiconst.CENTER, height=BOTTOM_CONT_HEIGHT) 181 GlowSprite(parent=self.completedCont, name='completedSprite', align=uiconst.TOLEFT, texturePath='res:/UI/Texture/classes/careerPortal/rewardBar_completedCrate.png', width=32) 182 textContainer = ContainerAutoSize(parent=self.completedCont, name='textCont', align=uiconst.TOLEFT) 183 EveLabelMedium(parent=textContainer, name='completedLabel', align=uiconst.CENTERLEFT, text=GetByLabel('UI/CareerPortal/GoalCompleted'), color=eveColor.LEAFY_GREEN, bold=True) 184 185 def OnTrackButtonPressed(self, goalID, button): 186 isTracked = get_career_portal_controller_svc().is_goal_tracked(goalID) 187 if isTracked: 188 get_career_portal_controller_svc().untrack_goal(goalID) 189 else: 190 PlaySound('career_portal_mission_view_play') 191 get_career_portal_controller_svc().track_goal(goalID) 192 193 def OnGoalTrackingAdded(self, goalID): 194 if not self.goal: 195 return 196 if goalID == self.goal.goal_id: 197 self._SetButtonToTrackedState() 198 199 def OnGoalTrackingRemoved(self, goalID): 200 if not self.goal: 201 return 202 if goalID == self.goal.goal_id: 203 self._SetButtonToUntrackedState() 204 205 def OnGoalCompleted(self, goalID): 206 if not self.goal: 207 return 208 if goalID == self.goal.goal_id: 209 self._HideTrackedButton(animate=True) 210 self._ShowCompletedState(animate=True) 211 212 def _HideTrackedButton(self, animate = False): 213 if animate: 214 animations.FadeOut(self.trackButton, duration=COMPLETION_FADE_IN_DURATION) 215 else: 216 self.trackButton.opacity = 0.0 217 218 def _ShowTrackedButton(self): 219 self.trackButton.opacity = 1.0 220 221 def _HideCompletedState(self): 222 self.completedCont.Hide() 223 224 def _ShowCompletedState(self, animate = False): 225 self.completedCont.Show() 226 if animate: 227 animations.FadeIn(self.completedCont, duration=COMPLETION_FADE_IN_DURATION) 228 else: 229 self.completedCont.opacity = 1.0 230 231 def _SetButtonToTrackedState(self): 232 self.trackButton.variant = ButtonVariant.NORMAL 233 self.trackButton.SetLabel(GetByLabel('UI/CareerPortal/UntrackGoal')) 234 self.trackButton.texturePath = 'res:/UI/Texture/classes/careerPortal/circleView/eye_closed_32.png' 235 236 def _SetButtonToUntrackedState(self): 237 self.trackButton.variant = ButtonVariant.PRIMARY 238 self.trackButton.SetLabel(GetByLabel('UI/CareerPortal/TrackGoal')) 239 self.trackButton.texturePath = 'res:/UI/Texture/classes/careerPortal/circleView/eye_open_32.png'