Originally Posted by sirinsidiator
Maybe you can make a small library instead of everyone making their own version?
That way you don't have to do anything special to make it work between your addons.
|
For our addons it would need the same code, both Advanced Filters & FilterIt use the default inventory menu bar
(with a subBar), but how would AGS or other addons that want to use their own menu bar handle it? Do you still want to use a flag to decide which filter bars get shown? If were doing it in a library I'de rather not watch for loading addons. That would force library updates if addons make changes or new addons are released wanting to use their own bars as well like AGS.
Example Lib:
Warning: Spoiler
Lua Code:
-- Register with LibStub
local MAJOR, MINOR = "LibTradeSellFilters", 1
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end -- the same or newer version of this lib is already loaded into memory
do
local layoutData = BACKPACK_TRADING_HOUSE_LAYOUT_FRAGMENT.layoutData
local sellFiltersEnabled = layoutData.sellFiltersEnabled
-- Give AGS & others a chance to block
-- this code from being run ??
if sellFiltersEnabled then return end
layoutData.sellFiltersEnabled = true
layoutData.inventoryTopOffsetY = 43
layoutData.hiddenFilters = { [ITEMFILTERTYPE_QUEST] = true }
local origAdditionalFilter = layoutData.additionalFilter
layoutData.additionalFilter = function (slot)
return origAdditionalFilter(slot) and (not IsItemBound(slot.bagId, slot.slotIndex))
end
-- Prehook HandleTabSwitch for sell mode:
local function OnHandleTabSwitch(self, tabData)
local mode = tabData.descriptor
if mode == ZO_TRADING_HOUSE_MODE_SELL then
ZO_PlayerInventoryTabs:SetHidden(false)
end
return false
end
ZO_PreHook(TRADING_HOUSE, "HandleTabSwitch", OnHandleTabSwitch)
end
Then for an addon like AGS that doesn't want to use those bars you could check to see if the flag is set & if not set it and use your bars.
One other problem, if we use a library, it will pretty much be whichever addon loads first wins without giving the user an option to select which bars to use, unless someone has a suggestion on how to handle that part.