browserAllStructures.py (8446B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureBrowser\browserAllStructures.py 2 import evetypes 3 import gametime 4 import uthread 5 from carbon.common.script.util.timerstuff import AutoTimer 6 from carbonui.primitives.container import Container 7 from carbonui.util.bunch import Bunch 8 from eve.client.script.ui.control.eveScroll import Scroll 9 from eve.client.script.ui.control.scrollUtil import TabFinder 10 from eve.client.script.ui.structure import ChangeSignalConnect 11 from eve.client.script.ui.structure.structureBrowser import browserUIConst 12 from eve.client.script.ui.structure.structureBrowser.controllers.filterContController import FilterContControllerAllStructures 13 from eve.client.script.ui.structure.structureBrowser.filterCont import FilterContAllStructures 14 from eve.client.script.ui.structure.structureBrowser.entries.structureEntry import StructureEntry 15 from eve.client.script.ui.structure.structureBrowser.controllers.structureEntryController import StructureEntryController 16 from eve.client.script.ui.structure.structureBrowser.filterContUtil import STATION_TYPE_CONFIGID, IsFilteredOutByText, IsFilteredOutByServices 17 from inventorycommon.util import IsNPC 18 from localization import GetByLabel 19 import log 20 OWNER_ANY = 1 21 OWNER_NPC = 2 22 OWNER_CORP = 3 23 24 class BrowserAllStructures(Container): 25 default_name = 'BrowserAllStructures' 26 27 def ApplyAttributes(self, attributes): 28 Container.ApplyAttributes(self, attributes) 29 self.controller = attributes.structureBrowserController 30 self.filterContController = FilterContControllerAllStructures() 31 self.ChangeSignalConnection(connect=True) 32 self.isInitialized = False 33 self.serviceChangedTimer = None 34 self.serviceChangedTimestamp = gametime.GetWallclockTimeNow() 35 36 def ChangeSignalConnection(self, connect = True): 37 signalAndCallback = [(self.controller.on_structures_changed, self.OnStructuresChanged), 38 (self.filterContController.on_change_location_range, self.OnLocationRangeChanged), 39 (self.filterContController.on_change_owner_value, self.OnOwnerValueChanged), 40 (self.filterContController.on_text_filter_changed, self.OnTextFilterChanged), 41 (self.filterContController.on_structure_type_changed, self.OnStructureTypeChanged), 42 (self.filterContController.structureTypeFilterController.on_filter_changed, self.OnStructuresChanged), 43 (self.filterContController.serviceFilterController.on_filter_changed, self.OnServiceSettingsChanged)] 44 ChangeSignalConnect(signalAndCallback, connect) 45 46 def OnTabSelect(self): 47 self.LoadPanel() 48 49 def LoadPanel(self): 50 self.display = True 51 if self.isInitialized: 52 self.UpdateScroll() 53 return 54 self.isInitialized = True 55 self.comboCont = FilterContAllStructures(name='filterCont', parent=self, filterContController=self.filterContController, padBottom=8) 56 self.scroll = Scroll(parent=self, id='AllStructuresScroll') 57 self.scroll.GetTabStops = self.GetTabStops 58 self.scroll.sr.fixedColumns = StructureEntry.GetFixedColumns() 59 self.scroll.OnSelectionChange = self.OnScrollSelectionChange 60 self.UpdateScroll() 61 62 def GetTabStops(self, headertabs, idx = None): 63 return TabFinder().GetTabStops(self.scroll.sr.nodes, headertabs, StructureEntry, idx=idx) 64 65 def UpdateScroll(self): 66 if not self.isInitialized: 67 return 68 if self.filterContController.AreServiceFiltersDisbled(): 69 structureServicesChecked = browserUIConst.ALL_SERVICES 70 else: 71 structureServicesChecked = self.filterContController.GetServicesChecked() 72 self.scroll.ShowLoading() 73 scrollList, somethingFilteredOut = self.GetScrollList(structureServicesChecked) 74 if somethingFilteredOut: 75 noContentHint = GetByLabel('UI/Structures/Browser/NoStructuresFoundWithFilters') 76 else: 77 noContentHint = GetByLabel('UI/Structures/Browser/NoStructuresFound') 78 self.scroll.LoadContent(contentList=scrollList, headers=StructureEntry.GetHeaders(structureServicesChecked), noContentHint=noContentHint) 79 self.scroll.HideLoading() 80 81 def IsFilteredOut(self, structureController): 82 if self._IsFilteredByOwner(structureController): 83 return True 84 if self._IsFilteredOutByStructureType(structureController): 85 return True 86 if self._IsFilteredOutByText(structureController): 87 return True 88 if self._IsFilteredOutByServices(structureController): 89 return True 90 return False 91 92 def _IsFilteredByOwner(self, structureController): 93 ownerValue = self.filterContController.GetStructureOwnerValue() 94 if ownerValue == browserUIConst.OWNER_ANY: 95 return False 96 ownerID = structureController.GetOwnerID() 97 if ownerValue == browserUIConst.OWNER_CORP: 98 if ownerID == session.corpid: 99 return False 100 else: 101 return True 102 if ownerValue == browserUIConst.OWNER_NPC: 103 if IsNPC(ownerID): 104 return False 105 else: 106 return True 107 return False 108 109 def _IsFilteredOutByStructureType(self, structureController): 110 if not self.filterContController.structureTypeFilterController.IsActive(): 111 return False 112 groupingsChecked = self.filterContController.GetStructureTypesChecked() 113 structureTypeID = structureController.GetTypeID() 114 if evetypes.GetCategoryID(structureTypeID) == const.categoryStation: 115 structureTypeID = STATION_TYPE_CONFIGID 116 if structureTypeID in groupingsChecked: 117 return False 118 else: 119 return True 120 121 def _IsFilteredOutByText(self, structureController): 122 filterText = self.filterContController.GetTextFilter() 123 return IsFilteredOutByText(structureController, filterText) 124 125 def _IsFilteredOutByServices(self, structureController): 126 filterContController = self.filterContController 127 return IsFilteredOutByServices(structureController, filterContController) 128 129 def GetScrollList(self, structureServicesChecked): 130 scrollList = [] 131 rangeSelected = self.filterContController.GetRange() 132 structureControllers = self.controller.GetAllStructures(rangeSelected) 133 somethingFilteredOut = False 134 for controller in structureControllers: 135 if self.IsFilteredOut(controller): 136 somethingFilteredOut = True 137 continue 138 node = Bunch(controller=controller, decoClass=StructureEntry, columnSortValues=StructureEntry.GetColumnSortValues(controller, structureServicesChecked), charIndex=controller.GetName(), structureServicesChecked=structureServicesChecked, GetSortValue=StructureEntry.GetSortValue) 139 scrollList.append(node) 140 141 return (scrollList, somethingFilteredOut) 142 143 def OnScrollSelectionChange(self, entries): 144 pass 145 146 def OnOwnerCombo(self, *args): 147 self.UpdateScroll() 148 149 def OnServiceSettingsChanged(self, *args): 150 uthread.new(self.OnServiceSettingsChanged_thread) 151 152 def OnServiceSettingsChanged_thread(self): 153 DELAY = 500 154 recentlyLoaded = gametime.GetTimeDiff(self.serviceChangedTimestamp, gametime.GetWallclockTimeNow()) / const.MSEC < DELAY 155 if recentlyLoaded: 156 self.serviceChangedTimer = AutoTimer(DELAY, self.DoUpdateScroll) 157 else: 158 self.DoUpdateScroll() 159 160 def DoUpdateScroll(self): 161 self.serviceChangedTimestamp = gametime.GetWallclockTimeNow() 162 self.serviceChangedTimer = None 163 self.UpdateScroll() 164 165 def OnOwnerValueChanged(self, value): 166 self.UpdateScroll() 167 168 def OnLocationRangeChanged(self, value): 169 self.UpdateScroll() 170 171 def OnTextFilterChanged(self): 172 self.UpdateScroll() 173 174 def OnStructureTypeChanged(self, value): 175 self.UpdateScroll() 176 177 def OnStructuresChanged(self, *args): 178 self.UpdateScroll() 179 180 def Close(self): 181 try: 182 self.ChangeSignalConnection(connect=False) 183 except Exception as e: 184 log.LogError('Failed at closing all structures browser, e = ', e) 185 finally: 186 self.controller = None 187 self.filterContController = None 188 Container.Close(self)