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

baseInfoWindow.py (4097B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\baseInfoWindow.py
      2 import uthread
      3 import uthread2
      4 from carbonui.control.window import Window
      5 from eve.client.script.ui.control.historyBuffer import HistoryBuffer
      6 
      7 class BaseInfoWindow(Window):
      8 
      9     def ApplyAttributes(self, attributes):
     10         self.infoType = None
     11         self.typeID = None
     12         self.itemID = None
     13         self.rec = None
     14         self.parentID = None
     15         self.abstractinfo = None
     16         self.isLoading = False
     17         self.pendingLoadData = None
     18         self.isBrowsing = False
     19         self.maintabs = None
     20         self.isUnlockedWithExpertSystem = None
     21         self.params = None
     22         self.reconstruct_thread = None
     23         self.history = HistoryBuffer()
     24         super(BaseInfoWindow, self).ApplyAttributes(attributes)
     25         if len(self.__notifyevents__) > 0:
     26             sm.RegisterNotify(self)
     27         typeID = attributes.get('typeID', None)
     28         itemID = attributes.get('itemID', None)
     29         rec = attributes.get('rec', None)
     30         parentID = attributes.get('parentID', None)
     31         abstractinfo = attributes.get('abstractinfo', None)
     32         selectTabType = attributes.get('selectTabType', None)
     33         params = attributes.get('params', None)
     34         self.params = params
     35         self.ConstructLayout()
     36         uthread.new(self.ReconstructInfoWindow, typeID, itemID, rec=rec, parentID=parentID, abstractinfo=abstractinfo, selectTabType=selectTabType, params=params)
     37 
     38     def ConstructLayout(self):
     39         pass
     40 
     41     def ReconstructInfoWindow(self, typeID, itemID = None, rec = None, parentID = None, abstractinfo = None, branchHistory = True, selectTabType = None, params = None):
     42         if self.isLoading:
     43             self.pendingLoadData = (typeID,
     44              itemID,
     45              rec,
     46              parentID,
     47              abstractinfo,
     48              branchHistory,
     49              selectTabType,
     50              params)
     51             return
     52         if branchHistory:
     53             self.history.Append(self.GetEmptyHistoryData())
     54         self._stop_reconstruct_thread()
     55         self.reconstruct_thread = uthread2.start_tasklet(self._ReconstructInfoWindow, typeID, itemID, rec, parentID, abstractinfo, branchHistory, selectTabType, params)
     56 
     57     def _ReconstructInfoWindow(self, typeID, itemID = None, rec = None, parentID = None, abstractinfo = None, branchHistory = True, selectTabType = None, params = None):
     58         if branchHistory and not self.history.IsEmpty():
     59             self.UpdateHistoryData(self.GetHistoryData())
     60         if self.pendingLoadData:
     61             pendingData = self.pendingLoadData
     62             self.pendingLoadData = None
     63             self.ReconstructInfoWindow(*pendingData)
     64 
     65     def _stop_reconstruct_thread(self, with_history = True):
     66         if self.reconstruct_thread is not None:
     67             if with_history:
     68                 if not self.history.IsEmpty() and self.history.GetCurrent()['typeID'] is None:
     69                     self.UpdateHistoryData(self.GetHistoryData())
     70             self.reconstruct_thread.kill()
     71             self.reconstruct_thread = None
     72 
     73     def UpdateHistoryData(self, history_data, append = False):
     74         self.history.UpdateCurrent(history_data)
     75         if append:
     76             self.history.Append(self.GetEmptyHistoryData())
     77 
     78     def GetEmptyHistoryData(self):
     79         return {'typeID': None,
     80          'itemID': None,
     81          'rec': None,
     82          'parentID': None,
     83          'abstractinfo': None,
     84          'selectTabType': None}
     85 
     86     def GetHistoryData(self):
     87         return (self.typeID,
     88          self.itemID,
     89          self.rec,
     90          self.parentID,
     91          self.abstractinfo,
     92          self.GetSelectedTabIdx())
     93 
     94     def GetSelectedTabIdx(self):
     95         if self.maintabs:
     96             return self.maintabs.GetSelectedIdx()
     97         else:
     98             return 0
     99 
    100     def Close(self, *args, **kwargs):
    101         try:
    102             self._stop_reconstruct_thread(with_history=False)
    103             sm.GetService('info').UnregisterWindow(self)
    104         finally:
    105             Window.Close(self, *args, **kwargs)