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

browserSkyhooks.py (5469B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureBrowser\browserSkyhooks.py
      2 import threadutils
      3 from carbonui.primitives.container import Container
      4 from carbonui.util.bunch import Bunch
      5 from eve.client.script.ui.control.eveScroll import Scroll
      6 from eve.client.script.ui.control.scrollUtil import TabFinder
      7 from eve.client.script.ui.structure.structureBrowser.controllers.filterContController import FilterContControllerSkyhook
      8 from eve.client.script.ui.structure.structureBrowser.entries.skyhookEntry import SkyhookEntry
      9 from eve.client.script.ui.structure.structureBrowser.filterCont import FilterContMySkyhooks
     10 from eve.client.script.ui.structure.structureBrowser.filterContUtil import IsFilteredOutByText
     11 from localization import GetByLabel
     12 OWNER_ANY = 1
     13 OWNER_NPC = 2
     14 OWNER_CORP = 3
     15 
     16 class BrowserAllSkyhooks(Container):
     17     default_name = 'BrowserAllSkyhooks'
     18 
     19     def ApplyAttributes(self, attributes):
     20         Container.ApplyAttributes(self, attributes)
     21         self.controller = attributes.skyhookController
     22         self.filterContController = FilterContControllerSkyhook()
     23         self.filterContController.on_filters_changed.connect(self._OnFiltersChanged)
     24         self.isInitialized = False
     25 
     26     def OnTabSelect(self):
     27         self.LoadPanel()
     28 
     29     def LoadPanel(self):
     30         self.display = True
     31         if self.isInitialized:
     32             self.UpdateScroll()
     33             return
     34         self.isInitialized = True
     35         self.comboCont = FilterContMySkyhooks(name='filterCont', parent=self, filterContController=self.filterContController, padBottom=8)
     36         self.scroll = Scroll(parent=self, id='mySkyhookScroll')
     37         self.scroll.GetTabStops = self.GetTabStops
     38         self.UpdateScroll()
     39 
     40     def GetTabStops(self, headertabs, idx = None):
     41         return TabFinder().GetTabStops(self.scroll.sr.nodes, headertabs, SkyhookEntry, idx=idx)
     42 
     43     @threadutils.throttled(0.5)
     44     def UpdateScroll(self):
     45         if not self.isInitialized:
     46             return
     47         self.scroll.ShowLoading()
     48         scrollList, somethingFilteredOut = self.GetScrollList()
     49         if somethingFilteredOut:
     50             noContentHint = GetByLabel('UI/Structures/Browser/NoStructuresFoundWithFilters')
     51         else:
     52             noContentHint = GetByLabel('UI/Structures/Browser/NoStructuresFound')
     53         self.scroll.LoadContent(contentList=scrollList, headers=SkyhookEntry.GetHeaders(), noContentHint=noContentHint)
     54         self.scroll.HideLoading()
     55 
     56     def IsFilteredOut(self, skyhookController):
     57         if self._IsFilteredOutByText(skyhookController):
     58             return True
     59         if self._IsFilteredOutByLocation(skyhookController):
     60             return True
     61         if self._IsFilteredOutByState(skyhookController):
     62             return True
     63         if self._IsFilteredOutByTheftVulnerability(skyhookController):
     64             return True
     65         return False
     66 
     67     def _IsFilteredOutByText(self, skyhookController):
     68         filterText = self.filterContController.GetTextFilter()
     69         return IsFilteredOutByText(skyhookController, filterText)
     70 
     71     def _IsFilteredOutByLocation(self, skyhookController):
     72         locationOption = self.filterContController.GetSelectedLocationOption()
     73         if locationOption is None:
     74             return False
     75         if locationOption == 1:
     76             return skyhookController.GetSolarSystemID() != session.solarsystemid2
     77         if locationOption == -1:
     78             regionID = self.filterContController.GetSelectedRegionOption() or session.regionid
     79             return skyhookController.GetRegionID() != regionID
     80         return skyhookController.GetNumJumps() > locationOption
     81 
     82     def _IsFilteredOutByState(self, skyhookController):
     83         stateOption = self.filterContController.GetSelectedStateOption()
     84         if stateOption is None:
     85             return False
     86         isVulnerable = skyhookController.IsVulnerable()
     87         if stateOption == 'vulnerable':
     88             return not isVulnerable
     89         if stateOption == 'reinforced':
     90             return isVulnerable
     91         return False
     92 
     93     def _IsFilteredOutByTheftVulnerability(self, skyhookController):
     94         stateOption = self.filterContController.GetSelectedTheftVulnerabilityOption()
     95         if stateOption is None:
     96             return False
     97         isVulnerable = skyhookController.IsTheftVulnerable()
     98         if stateOption == 'vulnerable':
     99             return not isVulnerable
    100         if stateOption == 'secure':
    101             return isVulnerable
    102         return False
    103 
    104     def GetScrollList(self):
    105         scrollList = []
    106         skyhookControllers = self.controller.GetMySkyhooks()
    107         somethingFilteredOut = False
    108         for controller in skyhookControllers:
    109             if self.IsFilteredOut(controller):
    110                 somethingFilteredOut = True
    111                 continue
    112             node = Bunch(controller=controller, decoClass=SkyhookEntry, columnSortValues=SkyhookEntry.GetColumnSortValues(controller), charIndex=controller.GetName(), GetSortValue=SkyhookEntry.GetSortValue)
    113             scrollList.append(node)
    114 
    115         return (scrollList, somethingFilteredOut)
    116 
    117     def _OnFiltersChanged(self):
    118         self.UpdateScroll()
    119 
    120     def Close(self):
    121         if self.filterContController:
    122             self.filterContController.on_filters_changed.disconnect(self._OnFiltersChanged)
    123         self.controller = None
    124         self.filterContController = None
    125         super(BrowserAllSkyhooks, self).Close()