NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

infoPanelAgentMissions.py (5993B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\infoPanels\infoPanelAgentMissions.py
      2 from eve.client.script.ui.shared.infoPanels.const.infoPanelConst import PANEL_MISSIONS
      3 from eve.client.script.ui.shared.infoPanels.infoPanelMissions import InfoPanelMissions, InfoPanelMissionData
      4 from functools import partial
      5 from eve.client.script.ui import eveColor
      6 from eve.client.script.ui.shared.pointerTool.pointerToolConst import UNIQUE_NAME_AGENT_MISSION_INFO_PANEL
      7 from localization import GetByLabel, GetByMessageID
      8 from missions.client.ui.missionObjectiveData import CreateObjective, TalkToAgent, ReadDetails, START_CONVERSATION_LABEL_PATH, START_CONVERSATION_ICON_PATH, READ_DETAILS_LABEL_PATH, READ_DETAILS_ICON_PATH
      9 from jobboard.client import get_job_board_service
     10 from jobboard.client.provider_type import ProviderType
     11 from uthread2 import StartTasklet
     12 
     13 class InfoPanelAgentMissionData(InfoPanelMissionData):
     14 
     15     def __init__(self, title, agentID, contentID, bookmarks, objectiveChain):
     16         self.agentID = agentID
     17         self.contentID = contentID
     18         self.bookmarks = bookmarks
     19         self.missionObjectivesTracker = sm.GetService('missionObjectivesTracker')
     20         self.objectiveChain = objectiveChain
     21         super(InfoPanelAgentMissionData, self).__init__(title)
     22 
     23     def _InitializeObjectives(self):
     24         self.objectives = []
     25         isCurrentObjective = False
     26         objectives = []
     27         currentObjective = self.missionObjectivesTracker.GetCurrentAgentMissionInfo(self.agentID)
     28         for index, objectiveData in enumerate(self.missionObjectivesTracker.GetAllAgentMissionInfo(self.agentID)):
     29             objective = CreateObjective(objectiveData, self.agentID, self.bookmarks, self.title)
     30             isCurrentObjective = self._IsCurrentObjective(objectiveData, currentObjective)
     31             objectives.append(objective)
     32             if isCurrentObjective:
     33                 objective.SetActive()
     34                 break
     35 
     36         if not isCurrentObjective:
     37             return
     38         self.objectives.extend(objectives)
     39 
     40     def _IsCurrentObjective(self, objective, currentObjective):
     41         objectiveStringList = [ str(item) for item in objective ] if objective else ['']
     42         return objectiveStringList == currentObjective
     43 
     44     def GetID(self):
     45         return self.agentID
     46 
     47     def GetContextMenu(self):
     48         from evemissions.client.qa_tools import get_agent_mission_context_menu
     49         result = get_agent_mission_context_menu(self.contentID, self.agentID)
     50         return result
     51 
     52     def GetStateColor(self):
     53         activeMission = sm.GetService('missionObjectivesTracker').agentMissions.get(self.agentID)
     54         if activeMission and activeMission.are_objectives_complete:
     55             return eveColor.SUCCESS_GREEN
     56 
     57 
     58 class InfoPanelAgentMissions(InfoPanelMissions):
     59     default_name = 'InfoPanelAgentMissions'
     60     uniqueUiName = UNIQUE_NAME_AGENT_MISSION_INFO_PANEL
     61     panelTypeID = PANEL_MISSIONS
     62     label = 'UI/PeopleAndPlaces/AgentMissions'
     63     default_iconTexturePath = 'res:/UI/Texture/Classes/InfoPanels/Missions.png'
     64     featureID = 'agent_mission'
     65 
     66     def ApplyAttributes(self, attributes):
     67         InfoPanelMissions.ApplyAttributes(self, attributes)
     68         self.missionObjectivesTracker = sm.GetService('missionObjectivesTracker')
     69 
     70     @staticmethod
     71     def IsAvailable():
     72         service = get_job_board_service()
     73         if service is not None and service.is_available:
     74             provider = service.get_provider(ProviderType.AGENT_MISSIONS)
     75             if provider.is_enabled:
     76                 return False
     77         return bool(sm.GetService('missionObjectivesTracker').GetAgentMissions())
     78 
     79     def ConstructNormal(self):
     80         super(InfoPanelAgentMissions, self).ConstructNormal()
     81 
     82     def GetMissions(self):
     83         missions = []
     84         for mission in self.missionObjectivesTracker.GetAgentMissions():
     85             missionName = self._GetAgentMissionName(mission.missionNameID)
     86             objectiveChain = self.missionObjectivesTracker.agentMissions[mission.agentID].objective_chain
     87             missionData = InfoPanelAgentMissionData(missionName, mission.agentID, mission.contentID, mission.bookmarks, objectiveChain)
     88             missions.append(missionData)
     89 
     90         return missions
     91 
     92     def _GetAgentMissionName(self, missionNameID):
     93         if isinstance(missionNameID, (int, long)):
     94             return GetByMessageID(missionNameID)
     95         return missionNameID
     96 
     97     def HasOptionsMenu(self):
     98         return True
     99 
    100     def GetOptionsMenu(self, menuParent, mission):
    101         menuParent.AddIconEntry(icon=READ_DETAILS_ICON_PATH, text=GetByLabel(READ_DETAILS_LABEL_PATH), callback=partial(ReadDetails, mission.agentID), name='utilmenu_MissionReadDetails')
    102         menuParent.AddIconEntry(icon=START_CONVERSATION_ICON_PATH, text=GetByLabel(START_CONVERSATION_LABEL_PATH), callback=partial(TalkToAgent, mission.agentID), name='utilmenu_MissionStartConversation')
    103 
    104     def UpdateExpandedStateForMissionID(self, agentID):
    105         expandedMissionIndex = self.GetIndexForMissionID(agentID)
    106         if self.expandedMissionIndex != expandedMissionIndex:
    107             self.UpdateExpandedStateForMission(expandedMissionIndex)
    108             if expandedMissionIndex is not None and self.scrollContainer and not self.scrollContainer.destroyed:
    109                 StartTasklet(self.ScrollToMission, expandedMissionIndex)
    110 
    111     def GetMissionIDForIndex(self, index):
    112         try:
    113             return self.missions[index].agentID
    114         except:
    115             return -1
    116 
    117     def GetIndexForMissionID(self, agentID):
    118         if agentID is not None:
    119             for missionIndex, mission in enumerate(self.missions):
    120                 if mission.agentID == agentID:
    121                     return missionIndex
    122 
    123     def GetDefaultExpandedMissionIndex(self):
    124         expandedMissionAgentID = self.missionObjectivesTracker.GetAgentForLastAcceptedMission()
    125         return self.GetIndexForMissionID(expandedMissionAgentID)