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

agentContentPiece.py (11096B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\agencyNew\contentPieces\agentContentPiece.py
      2 from carbonui.util.bunch import Bunch
      3 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import WarpToItem
      4 from eve.client.script.ui.shared.agencyNew import agencyConst
      5 from eve.client.script.ui.shared.agencyNew.contentPieces.baseContentPiece import BaseContentPiece
      6 from eve.client.script.ui.shared.agencyNew.agencyConst import AGENT_STANDARDDIVISIONIDS
      7 from eve.client.script.ui.shared.agencyNew.ui import agencyUIConst
      8 from eve.client.script.ui.shared.comtool.constants import CHANNEL_MISSIONS
      9 from eve.client.script.ui.station.agents import agentUtil
     10 from eve.client.script.ui.station.agents.agentUtil import GetAgentStandingThreshold, GetAgentDerivedStanding
     11 from eve.common.lib import appConst
     12 from localization import GetByLabel
     13 from npcs.divisions import get_division_name
     14 
     15 class AgentContentPiece(BaseContentPiece):
     16     contentType = agencyConst.CONTENTTYPE_AGENTS
     17 
     18     def __init__(self, agent = None, *args, **kwargs):
     19         BaseContentPiece.__init__(self, *args, **kwargs)
     20         self.agent = agent
     21 
     22     def GetTitle(self):
     23         activeMission = self.GetActiveMissionForAgent()
     24         if activeMission:
     25             return '%s: %s' % (self.GetAgentTypeName(), activeMission.GetMissionTypeText())
     26         else:
     27             return self.GetAgentTypeName()
     28 
     29     def GetExpandedTitle(self):
     30         return self.GetAgentNameAndLevel()
     31 
     32     def GetAgentID(self):
     33         return self.agent.agentID
     34 
     35     def GetDivisionName(self):
     36         return get_division_name(self.GetDivisionID())
     37 
     38     def GetDivisionID(self):
     39         return self.agent.divisionID
     40 
     41     def GetAgentTypeName(self):
     42         return GetByLabel('UI/Agency/AgentTypeName', divisionName=self.GetDivisionName())
     43 
     44     def GetActiveMissionForAgent(self):
     45         return sm.GetService('journal').GetActiveMissionForAgent(self.agent.agentID)
     46 
     47     def IsActiveAndAcceptedMission(self):
     48         activeMission = self.GetActiveMissionForAgent()
     49         if activeMission:
     50             return activeMission.IsMissionAccepted()
     51         else:
     52             return False
     53 
     54     def GetSubtitle(self):
     55         return self.GetAgentNameAndLevel()
     56 
     57     def GetAgentName(self):
     58         return cfg.eveowners.Get(self.GetAgentID()).ownerName
     59 
     60     def GetAgentCorpName(self):
     61         return cfg.eveowners.Get(self.GetCorpID()).ownerName
     62 
     63     def GetAgentNameAndLevel(self):
     64         return GetByLabel('UI/Agents/AgentNameAndLevel', charid=self.GetAgentID(), level=self.GetAgentLevel())
     65 
     66     def GetAgentLevel(self):
     67         return self.agent.level
     68 
     69     def GetAgentDivisionAndLevel(self):
     70         return '%s - %s' % (self.GetDivisionName(), GetByLabel('UI/Agents/AgentEntry/Level', level=self.GetAgentLevel()))
     71 
     72     def GetExpandedSubtitle(self):
     73         return self.GetAgentTypeName()
     74 
     75     def GetExpiryTimeText(self):
     76         activeMission = self.GetActiveMissionForAgent()
     77         if activeMission:
     78             return '%s %s' % (activeMission.GetMissionStateTextColored(), activeMission.GetExpiryTimeText(short=True))
     79 
     80     def IsActiveMissionExpired(self):
     81         activeMission = self.GetActiveMissionForAgent()
     82         if activeMission:
     83             return activeMission.IsExpired()
     84 
     85     def GetTimeRemaining(self):
     86         activeMission = self.GetActiveMissionForAgent()
     87         if activeMission:
     88             return activeMission.GetTimeRemaining()
     89 
     90     def GetCardSortValue(self):
     91         systemSec = self.GetSystemSecurityStatus()
     92         return (self._GetActiveMissionSortKey(),
     93          self._GetDivisionSortKey(),
     94          self.GetJumpsToSelfFromCurrentLocation(),
     95          -systemSec)
     96 
     97     def _GetDivisionSortKey(self):
     98         if self.IsStorylineAgent():
     99             return -1
    100         return AGENT_STANDARDDIVISIONIDS.index(self.GetDivisionID())
    101 
    102     def IsStorylineAgent(self):
    103         return self.agent.agentTypeID in (appConst.agentTypeStorylineMissionAgent, appConst.agentTypeGenericStorylineMissionAgent)
    104 
    105     def IsCareerAgent(self):
    106         return False
    107 
    108     def IsLocatorAgent(self):
    109         return self.agent.isLocatorAgent
    110 
    111     def _GetActiveMissionSortKey(self):
    112         activeMission = self.GetActiveMissionForAgent()
    113         if activeMission:
    114             return activeMission.GetActiveMissionSortKey()
    115         else:
    116             return 10000000000.0
    117 
    118     def _GetButtonState(self):
    119         if self.IsInCurrentStation() or not self.IsAvailable():
    120             return agencyUIConst.ACTION_STARTCONVERSATION
    121         else:
    122             return super(AgentContentPiece, self)._GetButtonState()
    123 
    124     def _ExecutePrimaryFunction(self, actionID):
    125         if actionID == agencyUIConst.ACTION_STARTCONVERSATION:
    126             self.ExecuteStartConversation()
    127         else:
    128             BaseContentPiece._ExecutePrimaryFunction(self, actionID)
    129 
    130     def ExecuteStartConversation(self):
    131         sm.GetService('agents').OpenDialogueWindow(self.itemID)
    132 
    133     def _GetButtonLabel(self, buttonState):
    134         if buttonState == agencyUIConst.ACTION_STARTCONVERSATION:
    135             return GetByLabel('UI/Chat/StartConversationAgent')
    136         else:
    137             return BaseContentPiece._GetButtonLabel(self, buttonState)
    138 
    139     def GetMenu(self):
    140         agentID = self.GetDestinationAgentID()
    141         return sm.GetService('menu').CharacterMenu(agentID)
    142 
    143     def GetBlurbText(self):
    144         if self.IsStorylineAgent():
    145             return GetByLabel('UI/Agency/Blurbs/StorylineAgent')
    146         if self.agent.divisionID == appConst.corpDivisionSecurity:
    147             return GetByLabel('UI/Agency/Blurbs/SecurityAgent')
    148         if self.agent.divisionID == appConst.corpDivisionMining:
    149             return GetByLabel('UI/Agency/Blurbs/MiningAgent')
    150         if self.agent.divisionID == appConst.a:
    151             return GetByLabel('UI/Agency/Blurbs/DistributionAgent')
    152 
    153     def GetActivityBadgeTexturePath(self):
    154         if self.IsStorylineAgent():
    155             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_storylineMissions.png'
    156         if self.IsCareerAgent():
    157             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_careerAgents.png'
    158         if self.agent.agentTypeID == appConst.agentTypeResearchAgent:
    159             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_agentsResearch.png'
    160         if self.agent.divisionID == appConst.corpDivisionSecurity:
    161             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_agentsSecurity.png'
    162         if self.agent.divisionID == appConst.corpDivisionMining:
    163             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_agentsMining.png'
    164         if self.agent.divisionID == appConst.corpDivisionDistribution:
    165             return 'res:/UI/Texture/classes/agency/ActivityBadges/badge_agentsDistribution.png'
    166 
    167     def GetActivityBadgeHintPath(self):
    168         if self.IsStorylineAgent():
    169             return 'UI/Agents/AgentEntry/StorylineAgent'
    170         if self.agent.agentTypeID == appConst.agentTypeResearchAgent:
    171             return 'Character/CareerGoals/Industrialist/GroupNames/Research'
    172         if self.agent.divisionID == appConst.corpDivisionSecurity:
    173             return 'Character/CareerGoals/Enforcer/GroupNames/SecurityAgent'
    174         if self.agent.divisionID == appConst.corpDivisionMining:
    175             return 'Character/CareerGoals/Industrialist/GroupNames/MiningAgent'
    176         if self.agent.divisionID == appConst.corpDivisionDistribution:
    177             return 'Character/CareerGoals/Industrialist/GroupNames/DistributionAgent'
    178 
    179     def GetEnemyOwnerID(self):
    180         activeMission = self.GetActiveMissionForAgent()
    181         if not activeMission:
    182             return None
    183         return activeMission.GetEnemyFactionID()
    184 
    185     def GetRewardTypes(self):
    186         agentType = self.agent.agentTypeID
    187         iskReward = self._GetIskRewardType()
    188         if agentType == appConst.corpDivisionSecurity:
    189             return [iskReward, agencyConst.REWARDTYPE_LP1, agencyConst.REWARDTYPE_LOOT]
    190         else:
    191             return [iskReward, agencyConst.REWARDTYPE_LP1]
    192 
    193     def _GetIskRewardType(self):
    194         level = self.GetAgentLevel()
    195         if level < 2:
    196             return agencyConst.REWARDTYPE_ISK1
    197         elif level < 4:
    198             return agencyConst.REWARDTYPE_ISK2
    199         else:
    200             return agencyConst.REWARDTYPE_ISK3
    201 
    202     def IsAvailable(self):
    203         return agentUtil.IsAgentAvailable(self.GetAgentID())
    204 
    205     def GetStanding(self):
    206         return GetAgentDerivedStanding(self.GetAgentID())[0]
    207 
    208     def GetRequiredStanding(self):
    209         return GetAgentStandingThreshold(self.GetAgentLevel())
    210 
    211     def GetBGVideoPath(self):
    212         if self.IsStorylineAgent():
    213             return 'res:/Video/Agency/agentStoryline.webm'
    214         if self.agent.divisionID == appConst.corpDivisionSecurity:
    215             return 'res:/Video/Agency/agentSecurity.webm'
    216         if self.agent.divisionID == appConst.corpDivisionMining:
    217             return 'res:/Video/Agency/agentMining.webm'
    218         if self.agent.divisionID == appConst.corpDivisionDistribution:
    219             return 'res:/Video/Agency/agentDistribution.webm'
    220 
    221     def GetAllowedShipTypeIDs(self):
    222         activeMission = self.GetActiveMissionForAgent()
    223         if activeMission:
    224             return activeMission.GetAllowedShipTypeIDs()
    225 
    226     def IsShipRestrictionShown(self):
    227         activeMission = self.GetActiveMissionForAgent()
    228         if activeMission:
    229             if not activeMission.IsShipRestrictionInteresting():
    230                 return False
    231         return BaseContentPiece.IsShipRestrictionShown(self)
    232 
    233     def GetContentSubTypeID(self):
    234         return self.GetDivisionID()
    235 
    236     def GetDragData(self):
    237         agentID = self.GetAgentID()
    238         dragData = Bunch()
    239         dragData.__guid__ = 'listentry.User'
    240         dragData.itemID = agentID
    241         dragData.charID = agentID
    242         dragData.info = Bunch(typeID=appConst.typeCharacter, name=cfg.eveowners.Get(agentID).name)
    243         return [dragData]
    244 
    245     def GetDestinationAgentID(self):
    246         mission = self.GetActiveMissionForAgent()
    247         if mission:
    248             return mission.GetDestinationAgentID()
    249         else:
    250             return self.GetAgentID()
    251 
    252     def GetDestinationSolarSystemID(self):
    253         destAgent = self.GetDestinationAgent()
    254         return destAgent.solarsystemID
    255 
    256     def GetDestinationAgent(self):
    257         destAgentID = self.GetDestinationAgentID()
    258         destinationAgent = sm.GetService('agents').GetAgentByID(destAgentID)
    259         return destinationAgent
    260 
    261     def GetStationID(self):
    262         destAgent = self.GetDestinationAgent()
    263         if destAgent:
    264             return destAgent.stationID
    265 
    266     def IsInCurrentSolarSystem(self):
    267         destAgent = self.GetDestinationAgent()
    268         return destAgent.solarsystemID == session.solarsystemid2
    269 
    270     def _ExecuteWarpTo(self):
    271         stationID = self.GetStationID()
    272         if stationID:
    273             WarpToItem(stationID)
    274         else:
    275             sm.GetService('agents').GetAgentMoniker(self.GetDestinationAgentID()).WarpToAgentInSpace()
    276 
    277     def GetChatChannelID(self):
    278         return CHANNEL_MISSIONS