invPanel.py (26502B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\invPanel.py 2 import blue 3 import telemetry 4 import eveicon 5 import evetypes 6 import inventorycommon.const as invConst 7 import itertoolsext 8 import localization 9 import threadutils 10 import uthread 11 import uthread2 12 from carbonui import uiconst 13 from carbonui.control.buttonIcon import ButtonIcon 14 from carbonui.control.combo import Combo 15 from carbonui.control.comboEntryData import ComboEntryData 16 from carbonui.primitives.container import Container 17 from carbonui.primitives.containerAutoSize import ContainerAutoSize 18 from carbonui.primitives.flowcontainer import FlowContainer 19 from carbonui.uicore import uicore 20 from carbonui.util.sortUtil import SortListOfTuples 21 from eve.client.script.ui.control.historyBuffer import HistoryBuffer 22 from eve.client.script.ui.shared.container import InvContQuickFilter, InvContViewBtns 23 from eve.client.script.ui.shared.fitting.fittingUtil import EatSignalChangingErrors, IsCharge 24 from eve.client.script.ui.shared.fittingScreen import BTN_TYPE_RESOURCES, CHARGE_FILTER_ALL_CHARGES, CHARGE_FILTER_NONE, BTN_TYPE_LOSLOT, BTN_TYPE_MEDSLOT, BTN_TYPE_HISLOT, BTN_TYPE_RIGSLOT, BTN_TYPE_DRONES, BTN_TYPE_SHIP, BTN_TYPE_SKILLS 25 from eve.client.script.ui.shared.fittingScreen.browsers.filterSettings import InventoryModuleSettings, InventoryChargeSettings 26 from eve.client.script.ui.shared.fittingScreen.browsers.filtering import GetValidTypeIDs 27 from eve.client.script.ui.shared.fittingScreen.filterBtn import DropdownFilter, FilterBtn 28 from eve.client.script.ui.shared.fittingScreen.fittingPanels.chargeButtons import ModuleChargeController 29 from eve.client.script.ui.shared.fittingScreen.invPanelSettings import _GetComboPrefsKey, GetInvComboSettingValue 30 from eve.client.script.ui.shared.fittingScreen.resourceBtnTooltip import LoadFilterBtnTooltipPanel 31 from eve.client.script.ui.shared.fittingScreen.settingUtil import IsInventorySelected 32 from eve.client.script.ui.shared.inventory.invConst import GetInventoryContainerClass, ContainerType 33 from eve.client.script.ui.shared.inventory.invFilters import InvFilters 34 from eve.client.script.ui.shared.inventory.treeData import TreeDataShipHangar, TreeDataStructure, TreeDataItemHangar, TreeDataShip 35 from eve.common.lib import appConst 36 from eve.common.script.sys.eveCfg import InShipInSpace, IsControllingStructure 37 from inventorycommon.const import VIEWMODE_ICONS, VIEWMODE_DETAILS, VIEWMODE_LIST, VIEWMODE_CARDS 38 from localization import GetByLabel 39 from shipfitting.fittingDogmaLocationUtil import GetHardware 40 from signals.signalUtil import ChangeSignalConnect 41 from uthread2 import BufferedCall 42 validCategoryIDs = (appConst.categoryCharge, 43 appConst.categoryCelestial, 44 appConst.categoryCommodity, 45 appConst.categoryDeployable, 46 appConst.categoryDrone, 47 appConst.categoryFighter, 48 appConst.categoryImplant, 49 appConst.categoryModule, 50 appConst.categoryShipSkin, 51 appConst.categoryShip, 52 appConst.categorySkill, 53 appConst.categoryStructureModule, 54 appConst.categorySubSystem) 55 HISTORY_LENGTH = 50 56 BTN_OPACITY_ACTIVE = 1.0 57 BTN_OPACITY_INACTIVE = 0.25 58 FILTER_TYPE_INV = 'inv' 59 60 class FittingInvPanel(Container): 61 default_clipChildren = True 62 default_padding = (0, 8, 0, 0) 63 default_availableViewModes = (VIEWMODE_ICONS, VIEWMODE_DETAILS, VIEWMODE_LIST) 64 __notifyevents__ = ['OnSessionChanged', 'OnInvFiltersChanged', 'OnItemNameChange'] 65 66 def ApplyAttributes(self, attributes): 67 Container.ApplyAttributes(self, attributes) 68 self.configName = attributes.configName 69 self.controller = attributes.controller 70 self.invCont = None 71 self.invController = None 72 self.refreshRequired = False 73 self.comboLoaded = False 74 self.refreshThread = None 75 self.pendingRefresh = False 76 self.chargeFilterCont = None 77 self.hwBtns = {} 78 self.history = HistoryBuffer(HISTORY_LENGTH) 79 self.module_filter_settings = InventoryModuleSettings() 80 self.charge_filter_settings = InventoryChargeSettings() 81 self.resource_filter_btn = None 82 self.chargeController = ModuleChargeController(self.charge_filter_settings, isToggle=False) 83 self.chargeController.on_selected_changed.connect(self.OnChargeSeletedChanged) 84 self.availableViewModes = attributes.get('availableViewModes', self.default_availableViewModes) 85 windowID = 'fittingInv' 86 self.invFilterCont = InvFilters(parent=self, settingsID='invFiltersHeight_%s' % windowID, minSize=100, maxSize=0.5, defaultSize=150, windowID=windowID, padBottom=2) 87 self.invFilterCont.on_filters_updated.connect(self.UpdateFilters) 88 prefsKey = _GetComboPrefsKey() 89 self.invCombo = Combo(parent=self, align=uiconst.TOTOP, options=[], callback=self.LoadInventoryLocationFromCombo, prefskey=prefsKey, select=None, maxVisibleEntries=Combo.default_maxVisibleEntries) 90 self.invCombo.GetScrollEntry = self.GetInvScrollEntry 91 self.filterCont = ContainerAutoSize(name='filterCont', parent=self, align=uiconst.TOTOP, padding=(0, 8, 0, 0)) 92 self.AddHardwareFilterButtons() 93 self.controlCont = Container(name='controlCont', parent=self, align=uiconst.TOTOP, height=24, padTop=8, clipChildren=True) 94 self.ConstructControls() 95 self.invContParent = Container(name='invContParent', parent=self, padTop=8) 96 self.invFilterCont.ExpandOrCollapeFilters() 97 sm.RegisterNotify(self) 98 sm.GetService('inv').Register(self) 99 self.ChangeSignalConnection(connect=True) 100 uthread2.start_tasklet(self.PopulateControls) 101 102 def ChangeSignalConnection(self, connect = True): 103 signalAndCallback = [(self.controller.on_new_itemID, self.OnSimulatedShipLoaded), 104 (self.controller.on_slots_changed, self.OnSlotsChanged), 105 (self.controller.on_simulation_state_changed, self.OnSimulationStateChanged), 106 (self.controller.on_subsystem_really_changed, self.OnSubsystemReallyChanged), 107 (self.controller.on_slots_updated, self.OnSlotsUpdated)] 108 ChangeSignalConnect(signalAndCallback, connect) 109 110 def PopulateControls(self): 111 self.ConstructFilters() 112 113 def ConstructControls(self): 114 self.quickFilter = InvContQuickFilter(parent=self.controlCont, align=uiconst.TORIGHT, width=120) 115 self.quickFilter.quickFilterInputBox.SetValue(self.module_filter_settings.text_filter.get()) 116 self.quickFilter._SetQuickFilterInput = self.SetQuickFilterInput 117 self.viewBtns = InvContViewBtns(parent=self.controlCont, align=uiconst.TOLEFT, controller=self) 118 self.goBackBtn = ButtonIcon(name='goBackBtn', parent=self.controlCont, align=uiconst.TOLEFT, left=8, width=24, iconSize=16, texturePath=eveicon.navigate_back, func=self.OnBack, hint=GetByLabel('UI/Control/EveWindow/Previous')) 119 self.goForwardBtn = ButtonIcon(name='goForwardBtn', parent=self.controlCont, align=uiconst.TOLEFT, width=24, iconSize=16, padRight=8, texturePath=eveicon.navigate_forward, func=self.OnForward, hint=GetByLabel('UI/Control/EveWindow/Next')) 120 self.UpdateHistoryButtons() 121 122 def SetInvContViewMode(self, value): 123 if self.invCont: 124 self.invCont.SetInvContViewMode(value) 125 126 @threadutils.throttled(2) 127 def UpdateComboThrottled(self): 128 if self.comboLoaded: 129 self.UpdateCombo() 130 131 @BufferedCall(2000) 132 def UpdateComboBuffered(self): 133 if self.comboLoaded: 134 self.UpdateCombo() 135 136 @telemetry.ZONE_METHOD 137 def UpdateCombo(self): 138 if InShipInSpace(): 139 allowedNodes = (TreeDataShip,) 140 else: 141 allowedNodes = (TreeDataShip, 142 TreeDataStructure, 143 TreeDataItemHangar, 144 TreeDataShipHangar) 145 treeData = sm.GetService('inv').GetInvLocationTreeData() 146 rootNodes = treeData.GetChildren() 147 sortedRootNodes = [] 148 for data in rootNodes: 149 if not isinstance(data, allowedNodes): 150 continue 151 idx = None 152 for i, nodeClass in enumerate(allowedNodes): 153 if isinstance(data, nodeClass): 154 idx = i 155 break 156 157 sortedRootNodes.append((idx, data)) 158 159 sortedRootNodes = SortListOfTuples(sortedRootNodes) 160 options = [] 161 for data in sortedRootNodes: 162 clsName = getattr(data, 'clsName', None) 163 entryData = ComboEntryData(label=data.GetLabel(), returnValue=(clsName, data.invController.itemID), icon=data.GetIcon()) 164 options.append(entryData) 165 if isinstance(data, TreeDataShipHangar): 166 continue 167 for child in data.GetChildren(): 168 childClsName = getattr(child, 'clsName', None) 169 if not childClsName: 170 continue 171 entryData = ComboEntryData(label=child.GetLabel(), returnValue=(childClsName, child.invController.itemID), icon=child.GetIcon(), indentLevel=1) 172 options.append(entryData) 173 174 select = self._FindSelectedOptionForCombo(options) 175 selectedBefore = self.invCombo.GetValue() 176 self.invCombo.LoadOptions(options, select) 177 if selectedBefore != self.invCombo.GetValue(): 178 self.invCombo.Confirm() 179 self.comboLoaded = True 180 181 def _FindSelectedOptionForCombo(self, options): 182 validInvIDs = [ x.returnValue for x in options if x.returnValue[0] is not None ] 183 if not validInvIDs: 184 return 185 selected = GetInvComboSettingValue() 186 if selected and selected in validInvIDs: 187 return selected 188 defaultOptions = (invConst.INVENTORY_ID_STATION_ITEMS, invConst.INVENTORY_ID_STRUCTURE_ITEMS) 189 defaultSelection = itertoolsext.first_or_default(validInvIDs, lambda x: x[0] in defaultOptions, None) 190 if defaultSelection: 191 return defaultSelection 192 return validInvIDs[0] 193 194 def AddHardwareFilterButtons(self): 195 self.hardwareFilterCont = FlowContainer(name='hardwareFilterCont', parent=self.filterCont, align=uiconst.TOTOP, padTop=4, contentSpacing=uiconst.BUTTONGROUPMARGIN) 196 self.construct_module_filters() 197 self.AddChargeFilter() 198 self.UpdateHardwareBtns() 199 200 def construct_module_filters(self): 201 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_lo_slot, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_LOSLOT, texturePath='res:/UI/Texture/classes/Fitting/filterIconLowSlot.png', hintLabelPath='UI/Fitting/FittingWindow/FilterLowSlot') 202 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_med_slot, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_MEDSLOT, texturePath='res:/UI/Texture/classes/Fitting/filterIconMediumSlot.png', hintLabelPath='UI/Fitting/FittingWindow/FilterMedSlot') 203 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_hi_slot, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_HISLOT, texturePath='res:/UI/Texture/classes/Fitting/filterIconHighSlot.png', hintLabelPath='UI/Fitting/FittingWindow/FilterHiSlot') 204 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_rig_slot, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_RIGSLOT, texturePath='res:/UI/Texture/classes/Fitting/filterIconRigSlot.png', hintLabelPath='UI/Fitting/FittingWindow/FilterRigSlot') 205 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_drones, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_DRONES, texturePath='res:/UI/Texture/classes/Fitting/filterIconDrones.png', hintLabelPath='UI/Fitting/FittingWindow/FilterDrones') 206 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_only_can_fit_to_current_ship, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_SHIP, texturePath='res:/UI/Texture/classes/Fitting/tabFittings.png', hintLabelPath='UI/Fitting/FittingWindow/FilterCanShipUse') 207 self.resource_filter_btn = FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_only_if_enough_resources, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_RESOURCES, texturePath='res:/UI/Texture/classes/Fitting/filterIconResources.png', hintLabelPath='UI/Fitting/FittingWindow/FilterResources') 208 FilterBtn(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, func=self.HardwareFilterClicked, setting=self.module_filter_settings.show_only_if_have_skills, hintFunc=self.LoadFilterBtnTooltipPanel, buttonType=BTN_TYPE_SKILLS, texturePath='res:/UI/Texture/classes/Fitting/filterIconSkills.png', hintLabelPath='UI/Fitting/FittingWindow/FilterSkills') 209 210 def AddChargeFilter(self): 211 hardwareList, options = self._GetChargeOptions() 212 options.insert(0, (GetByLabel('UI/Fitting/FittingWindow/All Charges'), CHARGE_FILTER_ALL_CHARGES)) 213 options.insert(0, (GetByLabel('UI/Fitting/FittingWindow/DeactivateFilter'), CHARGE_FILTER_NONE)) 214 self.chargeFilterCont = DropdownFilter(parent=self.hardwareFilterCont, align=uiconst.NOALIGN, hardwareList=hardwareList, options=options, chargeController=self.chargeController, select=self.chargeController.GetSelectModuleTypeID(), maxVisibleEntries=10) 215 if self.chargeFilterCont.GetValue() != self.chargeController.GetSelectModuleTypeID(): 216 self.chargeFilterCont.SetSelectedLook(CHARGE_FILTER_NONE) 217 218 def _GetChargeOptions(self): 219 hardwareList = GetHardware(self.controller.GetDogmaLocation()) 220 infoSvc = sm.GetService('info') 221 options = [] 222 for moduleTypeID in hardwareList: 223 chargeTypeIDs = infoSvc.GetUsedWithTypeIDs(moduleTypeID) 224 if not chargeTypeIDs: 225 continue 226 moduleName = evetypes.GetName(moduleTypeID) 227 options.append((moduleName, moduleTypeID)) 228 229 options = localization.util.Sort(options, key=lambda x: x[0]) 230 return (hardwareList, options) 231 232 def HardwareFilterClicked(self, filterBtn, buttonType): 233 isChargeFilterActive = self.chargeController.IsFilterActive() 234 if isChargeFilterActive: 235 self.chargeController.SetActiveState(False) 236 self.UpdateHardwareBtns() 237 self.Reload() 238 239 def LoadPanel(self): 240 if self.refreshRequired: 241 self.Reload() 242 if not self.comboLoaded: 243 self.UpdateCombo() 244 245 def Reload(self): 246 if not IsInventorySelected(): 247 self.refreshRequired = True 248 return 249 self.refreshRequired = False 250 self.pendingRefresh = True 251 refreshThreadIsRunning = self.IsRefreshThreadRunning() 252 if not refreshThreadIsRunning: 253 self.refreshThread = uthread.new(self._Refresh_thread) 254 255 def _Refresh_thread(self): 256 self.pendingRefresh = False 257 if self.invCont and not self.invCont.destroyed: 258 self.invCont.Refresh() 259 if self.pendingRefresh: 260 self._Refresh_thread() 261 262 def IsRefreshThreadRunning(self): 263 refreshThreadIsRunning = self.refreshThread and self.refreshThread.alive 264 return refreshThreadIsRunning 265 266 def LoadInventoryLocationFromCombo(self, cb, key, val): 267 if not val: 268 if self.invCont: 269 self.invCont.Hide() 270 self.filterCont.Hide() 271 self.controlCont.Hide() 272 return 273 if not self.invCont or self.invCont.invController.GetInvID() != val: 274 self.LoadInventory(invID=val) 275 276 def LoadInventory(self, invID, updateHistory = True): 277 invType, itemID = invID 278 self.filterCont.display = invType != ContainerType.STATION_SHIPS 279 self.controlCont.Show() 280 if updateHistory: 281 self.history.Append(invID) 282 self.invContParent.Flush() 283 invClass = GetInventoryContainerClass(invType) 284 self.invCont = invClass(name='fittingInv_%s' % itemID, parent=self.invContParent, itemID=itemID, activeFilters=self.GetActiveFilters()) 285 self.invController = self.invCont.invController 286 self.invCont.FilterItems = self.FilterItems 287 self.quickFilter.invCont = self.invCont 288 oldItemDataFunc = self.invCont.GetItemData 289 self.invCont.GetItemData = lambda *args, **kwargs: self.GetItemDataForInvCont(oldItemDataFunc, *args, **kwargs) 290 self.invCombo.SelectItemByValue(invID) 291 self.invCombo.UpdateSettings() 292 self.UpdateHistoryButtons() 293 self.ChangeResourceBtn() 294 295 def FilterItems(self, items): 296 if self.module_filter_settings.show_only_can_fit_to_current_ship.is_enabled(): 297 itemTypeIDs = {x.typeID for x in items if evetypes.GetCategoryID(x.typeID) in validCategoryIDs} 298 else: 299 itemTypeIDs = {x.typeID for x in items} 300 if self.chargeController.IsFilterActive(): 301 validTypeIDs = self.FilterForCharges(itemTypeIDs) 302 else: 303 searchFittingHelper = sm.GetService('fittingSvc').searchFittingHelper 304 validTypeIDs = GetValidTypeIDs(itemTypeIDs, searchFittingHelper, self.module_filter_settings, self.chargeController) 305 validItems = [ x for x in items if x.typeID in validTypeIDs ] 306 itemFilterSvc = sm.GetService('itemFilter') 307 for filter in self.GetActiveFilters(): 308 validItems = itemFilterSvc.FilterItems(validItems, filter) 309 310 if self.invCont.invController.filtersEnabled: 311 validItems = sm.GetService('itemFilter').ApplyTempFilter(validItems) 312 return validItems 313 314 def FilterForCharges(self, typeIDs): 315 selectedModuleTypeID = self.chargeController.GetSelectModuleTypeID() 316 if selectedModuleTypeID > 0: 317 usedWith = self.chargeController.GetUsedWithForSelectedModule() 318 return {x for x in typeIDs if x in usedWith} 319 if selectedModuleTypeID == CHARGE_FILTER_ALL_CHARGES: 320 return {x for x in typeIDs if IsCharge(x)} 321 return typeIDs 322 323 def GetItemDataForInvCont(self, oldItemDataFunc, rec, *args, **kwargs): 324 itemData = oldItemDataFunc(rec, *args, **kwargs) 325 itemData.openContainerFunc = self.OpenContainerFunc 326 return itemData 327 328 def OpenContainerFunc(self, invID, *args): 329 self.LoadInventory(invID) 330 uicore.registry.SetFocus(self) 331 332 def GetInvScrollEntry(self, entryData): 333 data = Combo.GetScrollEntry(self.invCombo, entryData) 334 if entryData.returnValue is not None: 335 clsName, itemID = entryData.returnValue 336 if clsName is None: 337 data['selectable'] = False 338 data['OnClick'] = None 339 return data 340 341 def OnInvChangeAny(self, item = None, change = None): 342 if not item or not change: 343 return 344 if item.categoryID != appConst.categoryCelestial: 345 return 346 if self._IsOldOrNewLocationInCombo(item, change): 347 self.UpdateComboThrottled() 348 349 def _IsOldOrNewLocationInCombo(self, item, change): 350 if not self.comboLoaded: 351 return False 352 if self.IsItemInCombo(item.locationID): 353 return True 354 oldLocationID = change.get(appConst.ixLocationID, None) 355 if oldLocationID and self.IsItemInCombo(oldLocationID): 356 return True 357 return False 358 359 def LoadFilterBtnTooltipPanel(self, tooltipPanel, filterBtn): 360 if filterBtn.buttonType != BTN_TYPE_RESOURCES: 361 return 362 isSimulated = self.controller.IsSimulated() 363 LoadFilterBtnTooltipPanel(tooltipPanel, filterBtn.hintLabelPath, self.module_filter_settings, self.Reload, isSimulated) 364 365 def SetQuickFilterInput(self, filterTxt): 366 if filterTxt: 367 blue.synchro.SleepWallclock(300) 368 self.module_filter_settings.text_filter.set(filterTxt) 369 self.Reload() 370 self.quickFilter.inputThread = None 371 372 def OnBack(self): 373 invID = self.history.GoBack() 374 if invID: 375 self.LoadInventory(invID, updateHistory=False) 376 self.UpdateHistoryButtons() 377 378 def OnForward(self): 379 invID = self.history.GoForward() 380 if invID: 381 self.LoadInventory(invID, updateHistory=False) 382 self.UpdateHistoryButtons() 383 384 def UpdateHistoryButtons(self): 385 if self.history.IsBackEnabled(): 386 self.goBackBtn.Enable() 387 else: 388 self.goBackBtn.Disable() 389 if self.history.IsForwardEnabled(): 390 self.goForwardBtn.Enable() 391 else: 392 self.goForwardBtn.Disable() 393 394 def OnSessionChanged(self, isRemote, sess, change): 395 if 'stationid' in change or 'structureid' in change or 'shipid' in change: 396 currentlySelected = self.invCombo.GetIndex() 397 self.UpdateCombo() 398 if currentlySelected == 0 and 'shipid' in change and not IsControllingStructure(): 399 self.invCombo.SelectItemByIndex(0) 400 self.invCombo.Confirm(0) 401 402 def OnInvFiltersChanged(self): 403 self.ConstructFilters() 404 self.UpdateFilters() 405 406 def OnItemNameChange(self, itemID, *args): 407 if self.IsItemInCombo(itemID): 408 self.UpdateComboBuffered() 409 410 def IsItemInCombo(self, itemID): 411 if not self.comboLoaded: 412 return False 413 for entryData in self.invCombo.GetSelectableEntries(): 414 if not entryData.returnValue: 415 continue 416 if len(entryData.returnValue) > 1 and entryData.returnValue[1] == itemID: 417 return True 418 419 return False 420 421 def OnSlotsChanged(self): 422 self.UpdateChargeFilters() 423 424 def UpdateChargeFilters(self): 425 if self.chargeFilterCont and not self.chargeFilterCont.destroyed: 426 self.chargeFilterCont.Close() 427 self.AddChargeFilter() 428 if self.controller.IsSimulated(): 429 if not self.controller.GetPreviewFittedItem() and self.module_filter_settings.mode_resources_on_output.is_enabled(): 430 self.Reload() 431 432 def OnSlotsUpdated(self): 433 _, options = self._GetChargeOptions() 434 if self.chargeFilterCont.entries[2:] != options: 435 self.UpdateChargeFilters() 436 437 def OnSimulationStateChanged(self): 438 if self.module_filter_settings.mode_resources_on_output.is_enabled(): 439 self.Reload() 440 self.ChangeResourceBtn() 441 442 def OnSimulatedShipLoaded(self, *args): 443 if IsInventorySelected(): 444 self.Reload() 445 446 def OnSubsystemReallyChanged(self, *args): 447 if self.module_filter_settings.show_only_can_fit_to_current_ship.is_enabled(): 448 self.Reload() 449 450 def UpdateFilters(self): 451 if self.invCont: 452 self.SetActiveFilters(self.GetActiveFilters()) 453 454 def SetActiveFilters(self, filters): 455 self.invCont.SetFilters(filters) 456 self.invFilterCont.SetActiveFilters(filters) 457 458 def GetActiveFilters(self): 459 filters = self.invFilterCont.GetActiveFilters() 460 return filters 461 462 def ConstructFilters(self): 463 self.invFilterCont.ConstructFilters() 464 465 def OnChargeSeletedChanged(self, selectedTypeID): 466 self.Reload() 467 self.UpdateHardwareBtns() 468 469 def UpdateHardwareBtns(self): 470 isChargeFilterActive = self.chargeController.IsFilterActive() 471 for btn in self.hwBtns.itervalues(): 472 if isChargeFilterActive: 473 btn.opacity = BTN_OPACITY_INACTIVE 474 else: 475 btn.opacity = BTN_OPACITY_ACTIVE 476 477 if isChargeFilterActive: 478 chargeToShow = self.chargeController.GetSelectModuleTypeID() 479 else: 480 chargeToShow = CHARGE_FILTER_NONE 481 self.chargeFilterCont.SetSelectedLook(chargeToShow, False) 482 483 def ChangeResourceBtn(self): 484 btn = self.resource_filter_btn 485 if not btn: 486 return 487 if self.controller.IsSimulated(): 488 btn.Enable() 489 else: 490 btn.Disable(opacity=0.3) 491 492 def FindTypeInInventory(self, typeID): 493 self.deselect_all_module_filter_buttons() 494 typeName = evetypes.GetName(typeID) 495 self.quickFilter.quickFilterInputBox.SetValue(typeName) 496 497 def deselect_all_module_filter_buttons(self): 498 self.module_filter_settings.show_lo_slot.disable() 499 self.module_filter_settings.show_med_slot.disable() 500 self.module_filter_settings.show_hi_slot.disable() 501 self.module_filter_settings.show_rig_slot.disable() 502 self.module_filter_settings.show_drones.disable() 503 504 def enable_one_module_filter_type(self, btn_type, *args): 505 self.quickFilter.ClearFilter() 506 self.module_filter_settings.show_lo_slot.set(btn_type == BTN_TYPE_LOSLOT) 507 self.module_filter_settings.show_med_slot.set(btn_type == BTN_TYPE_MEDSLOT) 508 self.module_filter_settings.show_hi_slot.set(btn_type == BTN_TYPE_HISLOT) 509 self.module_filter_settings.show_rig_slot.set(btn_type == BTN_TYPE_RIGSLOT) 510 self.Reload() 511 512 def Close(self): 513 with EatSignalChangingErrors(errorMsg='fitting wnd'): 514 if self.controller: 515 self.ChangeSignalConnection(connect=False) 516 self.invController = None 517 Container.Close(self) 518 519 def GetViewModeIcon(self, viewMode): 520 if viewMode == VIEWMODE_ICONS: 521 return eveicon.grid_view 522 if viewMode == VIEWMODE_DETAILS: 523 return eveicon.details_view 524 if viewMode == VIEWMODE_LIST: 525 return eveicon.list_view 526 if viewMode == VIEWMODE_CARDS: 527 return eveicon.edit 528 529 def GetViewModeName(self, viewMode): 530 if viewMode == VIEWMODE_ICONS: 531 return localization.GetByLabel('UI/Inventory/Icons') 532 if viewMode == VIEWMODE_DETAILS: 533 return localization.GetByLabel('UI/Inventory/Details') 534 if viewMode == VIEWMODE_LIST: 535 return localization.GetByLabel('UI/Inventory/List') 536 if viewMode == VIEWMODE_CARDS: 537 return localization.GetByLabel('UI/Inventory/CardsViewMode') 538 return localization.GetByLabel('UI/Generic/Unknown')