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

panelStandings.py (5681B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panelStandings.py
      2 from carbonui import uiconst
      3 from carbonui.control.scrollContainer import ScrollContainer
      4 from carbonui.primitives.container import Container
      5 from characterdata.factions import iter_faction_ids
      6 from eve.client.script.ui.shared.standings.standingData import StandingData
      7 from eve.client.script.ui.shared.standings.standingsSection import StandingsSection
      8 from eve.common.lib import appConst
      9 from eve.common.script.sys import idCheckers
     10 from localization import GetByLabel
     11 from npcs.npccorporations import get_corporation_faction_id
     12 
     13 class PanelStandings(Container):
     14     default_name = 'PanelStandings'
     15     default_padLeft = 4
     16     default_padRight = 4
     17 
     18     def ApplyAttributes(self, attributes):
     19         Container.ApplyAttributes(self, attributes)
     20         self.ownerID = attributes.ownerID
     21         self.isInitialized = False
     22         self.scrollContainer = ScrollContainer(parent=self)
     23 
     24     def Load(self):
     25         if self.isInitialized:
     26             return
     27         self.ConstructPanel()
     28         self.isInitialized = True
     29 
     30     def ConstructPanel(self):
     31         for captionText, ownerID, standingsData in self.GetStandingsDataSections():
     32             self.AddStandingsSection(captionText, ownerID, standingsData)
     33 
     34     def AddStandingsSection(self, captionText, ownerID, standingsData):
     35         StandingsSection(parent=self.scrollContainer, align=uiconst.TOTOP, text=captionText, ownerID=ownerID, padBottom=4, standingsData=standingsData)
     36 
     37     def GetStandingsDataSections(self):
     38         if idCheckers.IsNPC(self.ownerID):
     39             return self.GetStandingsDataSectionsNPC(self.ownerID)
     40         else:
     41             return self.GetStandingsDataSectionsPlayerOwner(self.ownerID)
     42 
     43     def GetStandingsDataSectionsNPC(self, ownerID):
     44         fromIDs = self.GetFromIDsForNPCOwner(ownerID)
     45         standingsTowardsMe = self.GetStandingsFromManyToOneRightToLeft(fromIDs, session.charid)
     46         ret = [(GetByLabel('UI/Standings/StandingsTowardsMe'), session.charid, standingsTowardsMe)]
     47         if idCheckers.IsFaction(ownerID):
     48             fromIDs = self.GetNPCFactionIDs()
     49             standingsToOtherFactions = self.GetStandingsFromManyToOneMutual(fromIDs, ownerID)
     50             ret.append((GetByLabel('UI/Standings/StandingsTowardsOtherFactions'), ownerID, standingsToOtherFactions))
     51         return ret
     52 
     53     def GetStandingsDataSectionsPlayerOwner(self, ownerID):
     54         fromIDs = [session.charid]
     55         if session.corpid and not idCheckers.IsNPC(session.corpid):
     56             fromIDs.append(session.corpid)
     57         if session.allianceid and not idCheckers.IsNPC(session.allianceid):
     58             fromIDs.append(session.allianceid)
     59         toIDs = self.GetToIDsForPlayerOwner(ownerID)
     60         return [ self._GetDataSection(fromIDs, toID) for toID in toIDs ]
     61 
     62     def _GetDataSection(self, fromIDs, toID):
     63         standingsTowards = self.GetStandingsFromManyToOneLeftToRight(fromIDs, toID)
     64         towards = ('My Standings Towards %s' % cfg.eveowners.Get(toID).ownerName, toID, standingsTowards)
     65         return towards
     66 
     67     def GetNPCFactionIDs(self):
     68         return [ factionID for factionID in iter_faction_ids() if factionID != appConst.factionUnknown ]
     69 
     70     def GetStandingsFromManyToOneMutual(self, fromIDs, ownerID1):
     71         return [ StandingData(ownerID1=ownerID1, ownerID2=ownerID2, standing1to2=self._GetStanding(ownerID1, ownerID2), standing2to1=self._GetStanding(ownerID2, ownerID1)) for ownerID2 in fromIDs if ownerID1 != ownerID2 ]
     72 
     73     def GetStandingsFromManyToOneRightToLeft(self, fromIDs, ownerID1):
     74         return [ StandingData(ownerID1=ownerID1, ownerID2=ownerID2, standing2to1=self._GetStanding(ownerID2, ownerID1)) for ownerID2 in fromIDs ]
     75 
     76     def GetStandingsFromManyToOneLeftToRight(self, fromIDs, ownerID2):
     77         return [ StandingData(ownerID1=ownerID1, ownerID2=ownerID2, standing1to2=self._GetStanding(ownerID1, ownerID2)) for ownerID1 in fromIDs ]
     78 
     79     def _GetStanding(self, fromID, toID):
     80         return sm.GetService('standing').GetStanding(fromID, toID)
     81 
     82     def GetFromIDsForNPCOwner(self, ownerID):
     83         if idCheckers.IsFaction(ownerID):
     84             fromIDs = (self.ownerID,)
     85         elif idCheckers.IsCorporation(ownerID):
     86             factionID = get_corporation_faction_id(ownerID)
     87             if factionID:
     88                 fromIDs = (ownerID, factionID)
     89             else:
     90                 fromIDs = (ownerID,)
     91         elif sm.GetService('agents').GetAgentByID(ownerID):
     92             agent = sm.GetService('agents').GetAgentByID(ownerID)
     93             agentFactionID = agent.factionID
     94             agentCorpID = agent.corporationID
     95             fromIDs = (ownerID, agentCorpID, agentFactionID)
     96         else:
     97             fromIDs = (ownerID,)
     98         return fromIDs
     99 
    100     def GetToIDsForPlayerOwner(self, ownerID):
    101         ret = [ownerID]
    102         if idCheckers.IsCharacter(ownerID):
    103             publicInfo = sm.RemoteSvc('charMgr').GetPublicInfo(ownerID)
    104             ownerCorpID = publicInfo.corporationID
    105             if not idCheckers.IsNPC(ownerCorpID):
    106                 ret.append(ownerCorpID)
    107             ownerAllianceID = self._GetOwnerAllianceID(ownerCorpID)
    108             if ownerAllianceID:
    109                 ret.append(ownerAllianceID)
    110         elif idCheckers.IsCorporation(ownerID):
    111             ownerAllianceID = self._GetOwnerAllianceID(ownerID)
    112             if ownerAllianceID:
    113                 ret.append(ownerAllianceID)
    114         return ret
    115 
    116     def _GetOwnerAllianceID(self, ownerCorpID):
    117         if not idCheckers.IsNPC(ownerCorpID):
    118             return sm.GetService('corp').GetCorporation(ownerCorpID).allianceID