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

assetsinfo.py (6842B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\assetsinfo.py
      2 import blue
      3 import localization
      4 import uthread
      5 from carbon.common.script.sys import service
      6 from carbonui.uicore import uicore
      7 from carbonui.util.various_unsorted import SortListOfTuples
      8 from eve.client.script.ui.shared.assetsWindow import AssetsWindow
      9 from eve.common.lib import appConst as const
     10 from eve.common.script.sys import idCheckers
     11 from playerprogression.assetnetworthnotifier import AssetNetWorthNotifier
     12 from playerprogression.plexprogressionnotifier import PlexProgressionNotifier
     13 
     14 class AssetsSvc(service.Service):
     15     __exportedcalls__ = {'SetHint': []}
     16     __guid__ = 'svc.assets'
     17     __notifyevents__ = ['OnSessionChanged',
     18      'OnItemChange',
     19      'OnItemNameChange',
     20      'OnPostCfgDataChanged']
     21     __servicename__ = 'assets'
     22     __displayname__ = 'Assets Client Service'
     23     __dependencies__ = []
     24     __update_on_reload__ = 0
     25 
     26     def Run(self, memStream = None):
     27         self.LogInfo('Starting Assets')
     28         self.locationCache = {}
     29         self.SetupAssetNetWorthNotifier()
     30         self.SetupPlexProgressionNotifier()
     31 
     32     def SetupAssetNetWorthNotifier(self):
     33         self.assetNetWorthNotifier = AssetNetWorthNotifier()
     34         self.SubscribeAssetNetWorthWatcher = self.assetNetWorthNotifier.register_subscriber
     35         self.UnsubscribeAssetNetWorthWatcher = self.assetNetWorthNotifier.unregister_subscriber
     36 
     37     def SetupPlexProgressionNotifier(self):
     38         self.plexWorthNotifier = PlexProgressionNotifier()
     39         self.SubscribePlexWorthWatcher = self.plexWorthNotifier.register_subscriber
     40         self.UnsubscribePlexWorthWatcher = self.plexWorthNotifier.unregister_subscriber
     41 
     42     def Stop(self, memStream = None):
     43         wnd = self.GetWnd()
     44         if wnd and not wnd.destroyed:
     45             wnd.Close()
     46 
     47     def OnSessionChanged(self, isremote, session, change):
     48         if session.charid is None:
     49             self.Stop()
     50         else:
     51             wnd = self.GetWnd()
     52             if wnd and not wnd.destroyed:
     53                 uthread.new(wnd.ReconstructLayout)
     54 
     55     def OnItemChange(self, item, change, location):
     56         itemLocationIDs = [item.locationID]
     57         if const.ixLocationID in change:
     58             itemLocationIDs.append(change[const.ixLocationID])
     59         wnd = self.GetWnd()
     60         if wnd and not wnd.destroyed:
     61             if change.keys() == [const.ixLocationID] and change.values() == [0]:
     62                 return
     63             if idCheckers.IsStation(item.locationID) or const.ixLocationID in change and idCheckers.IsStation(change[const.ixLocationID]):
     64                 key = wnd.tabGroup.GetSelectedArgs()
     65                 if key is not None:
     66                     if key[:7] == 'station':
     67                         if idCheckers.IsSolarSystem(item.locationID) and const.ixLocationID in change and change[const.ixLocationID] == session.stationid:
     68                             return
     69                         if session.stationid in itemLocationIDs:
     70                             wnd.tabGroup.ReloadVisible()
     71                     elif key in ('allitems', 'regitems', 'conitems', 'sysitems'):
     72                         uthread.new(wnd.UpdateLite, item.locationID, key, change.get(const.ixLocationID, item.locationID))
     73 
     74     def OnItemNameChange(self, *args):
     75         wnd = self.GetWnd(0)
     76         if wnd:
     77             wnd.ReconstructLayout()
     78 
     79     def Show(self, stationID = None):
     80         wnd = self.GetWnd(1)
     81         if wnd is not None and not wnd.destroyed:
     82             wnd.Maximize()
     83             if stationID is not None:
     84                 wnd.tabGroup.ShowPanelByName(localization.GetByLabel('UI/Inventory/AssetsWindow/AllItems'))
     85                 blue.pyos.synchro.Yield()
     86                 for entry in wnd.sr.scroll.GetNodes():
     87                     if entry.__guid__ == 'listentry.Group':
     88                         if entry.id == ('assetslocations_allitems', stationID):
     89                             uicore.registry.SetListGroupOpenState(('assetslocations_allitems', stationID), 1)
     90                             wnd.sr.scroll.PrepareSubContent(entry)
     91                             wnd.sr.scroll.ShowNodeIdx(entry.idx)
     92 
     93     def OnPostCfgDataChanged(self, what, data):
     94         if what == 'evelocations':
     95             wnd = self.GetWnd()
     96             if wnd is not None and not wnd.destroyed and wnd.key and wnd.key[:7] == 'station':
     97                 wnd.tabGroup.ReloadVisible()
     98 
     99     def GetAll(self, key, keyID = None, sortKey = 0):
    100         stations = self.GetStations()
    101         sortlocations = []
    102         mapSvc = sm.StartService('map')
    103         for station in stations:
    104             blue.pyos.BeNice()
    105             solarsystemID = station.solarSystemID
    106             loc = self.locationCache.get(solarsystemID, None)
    107             if loc is None:
    108                 constellationID = mapSvc.GetParent(solarsystemID)
    109                 loc = self.locationCache.get(constellationID, None)
    110                 if loc is None:
    111                     regionID = mapSvc.GetParent(constellationID)
    112                     loc = (solarsystemID, constellationID, regionID)
    113                 else:
    114                     regionID = loc[2]
    115                 self.locationCache[solarsystemID] = loc
    116                 self.locationCache[constellationID] = loc
    117                 self.locationCache[regionID] = loc
    118             else:
    119                 constellationID = loc[1]
    120                 regionID = loc[2]
    121             if key == 'allitems':
    122                 sortlocations.append((cfg.evelocations.Get(station.stationID).name, (solarsystemID, station)))
    123             elif key == 'sysitems':
    124                 if solarsystemID == (keyID or session.solarsystemid2):
    125                     sortlocations.append((cfg.evelocations.Get(station.stationID).name, (solarsystemID, station)))
    126             elif key == 'conitems' and constellationID == (keyID or session.constellationid):
    127                 sortlocations.append((cfg.evelocations.Get(station.stationID).name, (solarsystemID, station)))
    128             elif key == 'regitems' and regionID == (keyID or session.regionid):
    129                 sortlocations.append((cfg.evelocations.Get(station.stationID).name, (solarsystemID, station)))
    130 
    131         sortlocations = SortListOfTuples(sortlocations)
    132         return sortlocations
    133 
    134     def GetStations(self):
    135         stations = sm.GetService('invCache').GetInventory(const.containerGlobal).ListStations()
    136         primeloc = []
    137         for station in stations:
    138             primeloc.append(station.stationID)
    139 
    140         if len(primeloc):
    141             cfg.evelocations.Prime(primeloc)
    142         return stations
    143 
    144     def GetWnd(self, new = 0):
    145         if new:
    146             return AssetsWindow.Open()
    147         return AssetsWindow.GetIfOpen()
    148 
    149     def SetHint(self, hintstr = None):
    150         wnd = self.GetWnd()
    151         if wnd is not None:
    152             wnd.SetHint(hintstr)