objectivesteps.py (7555B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\agentinteraction\objectivesteps.py 2 import carbonui.text.styles 3 from evePathfinder.core import IsUnreachableJumpCount 4 from agentinteraction.constUI import PADDING_SMALL 5 from agentinteraction.objectivestep import ObjectiveStep 6 from agentinteraction.objectivetests import TEST_OBJECTIVE_SETS 7 from agentinteraction.textutils import fix_text 8 import carbonui 9 from carbonui import const as uiconst 10 from carbonui.primitives.containerAutoSize import ContainerAutoSize 11 from carbonui.util.color import Color 12 from eve.client.script.ui.station.agents.agentDialogueUtil import LocationWrapper 13 from eve.common.script.sys.idCheckers import IsStation, IsSolarSystem, IsShip 14 import evelink.client 15 from evemissions.client.objectives import TalkToAgentObjective, CargoObjective, PickUpObjective, DropOffObjective, DungeonObjective, ObjectivesType 16 from evetypes import GetCategoryID 17 from inventorycommon.util import GetPackagedVolume 18 from localization import GetByLabel 19 OBJECTIVES_LINE_COLOR = Color.GRAY5 20 PADDING_BETWEEN_STEPS_BEFORE = 4 21 PADDING_BETWEEN_STEPS_AFTER = 8 22 PADDING_AFTER_STEPS = 4 23 24 class ObjectiveSteps(ContainerAutoSize): 25 __notifyevents__ = ['OnDestinationSet'] 26 27 def ApplyAttributes(self, attributes): 28 super(ObjectiveSteps, self).ApplyAttributes(attributes) 29 self.test_set = attributes.get('test_set', None) 30 self._steps = None 31 self._objective_type = None 32 self.briefing = carbonui.text.styles.TextBody(name='briefing', parent=self, align=uiconst.TOTOP, padding=(0, 33 0, 34 0, 35 PADDING_SMALL), state=uiconst.UI_NORMAL) 36 self.steps_container = ContainerAutoSize(name='steps_container', parent=self, align=uiconst.TOTOP) 37 sm.RegisterNotify(self) 38 39 def Close(self): 40 sm.UnregisterNotify(self) 41 super(ObjectiveSteps, self).Close() 42 43 def OnDestinationSet(self, *args, **kwargs): 44 if self._steps: 45 self.steps_container.Flush() 46 self.update_objective_steps(self._steps, self._objective_type) 47 48 def update_objective_steps(self, steps, objective_type): 49 self._steps = steps 50 self._objective_type = objective_type 51 if self.test_set: 52 objective_type = self.test_set 53 steps = TEST_OBJECTIVE_SETS[objective_type] 54 number_of_steps = len(steps) 55 for order, step in enumerate(steps): 56 self._add_step(step, objective_type, order, number_of_steps) 57 58 def update_briefing(self, text): 59 if text: 60 text = fix_text(text) 61 self.briefing.SetText(text) 62 self.briefing.Show() 63 else: 64 self.briefing.Hide() 65 66 def _add_step(self, step, objectives_type, order, number_of_steps): 67 title = self._get_title(step) 68 text = self._get_text(step) 69 briefing = self._get_briefing(step, objectives_type) 70 location_info = self._get_location_info(step) 71 owner_id = self._get_owner_id(step) 72 is_last_step = order >= number_of_steps - 1 73 if is_last_step: 74 bottom_pad = PADDING_AFTER_STEPS 75 else: 76 bottom_pad = PADDING_BETWEEN_STEPS_AFTER 77 if order == 0: 78 top_pad = 0 79 else: 80 top_pad = PADDING_BETWEEN_STEPS_BEFORE 81 ObjectiveStep(name='container_step_%s' % step.name, parent=self.steps_container, align=uiconst.TOTOP, title_left=title, title_right=location_info, text=text, step_state=step.state, content_padding_bottom=bottom_pad, content_padding_top=top_pad, owner_id=owner_id, step=step) 82 self.update_briefing(briefing) 83 84 def _get_title(self, step): 85 if isinstance(step, TalkToAgentObjective): 86 return GetByLabel('UI/Agents/StandardMission/AgentLocation') 87 if isinstance(step, CargoObjective): 88 return GetByLabel('UI/Agents/StandardMission/TransportCargo') 89 if isinstance(step, PickUpObjective): 90 return GetByLabel('UI/Agents/StandardMission/TransportPickupLocation') 91 if isinstance(step, DropOffObjective): 92 return GetByLabel('UI/Agents/StandardMission/TransportDropOffLocation') 93 if isinstance(step, DungeonObjective): 94 return GetByLabel('UI/Agents/StandardMission/ObjectiveLocation') 95 return '' 96 97 def _get_text(self, step): 98 if isinstance(step, TalkToAgentObjective): 99 return LocationWrapper(step.location, 'agenthomebase') 100 if isinstance(step, CargoObjective): 101 type_id = step.type_id 102 category_id = GetCategoryID(type_id) 103 quantity = step.quantity 104 text = GetByLabel('UI/Common/QuantityAndItem', quantity=quantity, item=type_id) 105 if IsShip(category_id): 106 volume = GetPackagedVolume(type_id) 107 label = 'UI/Agents/StandardMission/CargoDescriptionWithSizePackaged' 108 else: 109 volume = step.volume 110 label = 'UI/Agents/StandardMission/CargoDescriptionWithSize' 111 if volume > 0: 112 text = GetByLabel(label, cargoDescription=text, size=volume) 113 return evelink.type_link(type_id, link_text=text) 114 if isinstance(step, PickUpObjective) or isinstance(step, DropOffObjective) or isinstance(step, DungeonObjective): 115 return LocationWrapper(step.location) 116 return '' 117 118 def _get_briefing(self, step, objectives_type): 119 if isinstance(step, TalkToAgentObjective): 120 return GetByLabel('UI/Agents/StandardMission/ObjectiveReportTo', agentLink=evelink.owner_link(step.agent_id)) 121 if isinstance(step, DropOffObjective): 122 if objectives_type == ObjectivesType.TRANSPORT: 123 return GetByLabel('UI/Agents/StandardMission/TransportBlurb') 124 if objectives_type == ObjectivesType.FETCH: 125 return GetByLabel('UI/Agents/StandardMission/FetchObjectiveBlurb') 126 if isinstance(step, DungeonObjective): 127 if step.briefing is not None: 128 return step.briefing 129 if step.is_killing_optional: 130 return GetByLabel('UI/Agents/StandardMission/OptionalObjectiveBody') 131 return GetByLabel('UI/Agents/StandardMission/DungeonObjectiveBody') 132 return '' 133 134 def _get_location_info(self, step): 135 location_info = '' 136 location = getattr(step, 'location', None) 137 if location: 138 location_id = location['locationID'] 139 solar_system_id = location['solarsystemID'] 140 current_solar_system_id = session.solarsystemid2 141 current_station = session.stationid 142 jumps = sm.GetService('clientPathfinderService').GetAutopilotJumpCount(session.solarsystemid2, solar_system_id) 143 if IsStation(location_id): 144 if current_station == location_id: 145 return GetByLabel('UI/Agents/StandardMission/ThisStation') 146 location_id = solar_system_id 147 if IsSolarSystem(location_id): 148 if current_solar_system_id == location_id: 149 return GetByLabel('UI/Agents/StandardMission/ThisSolarSystem') 150 elif IsUnreachableJumpCount(jumps): 151 return GetByLabel('UI/Generic/NoGateToGateRoute') 152 else: 153 return GetByLabel('UI/Agents/StandardMission/JumpsAway', jumps=jumps) 154 return location_info 155 156 def _get_owner_id(self, step): 157 if isinstance(step, TalkToAgentObjective): 158 return step.agent_id