1) Decile filter sounds really cool, but I don't really know what I would do with one. There is already a price filter, unit price filter and MM's deal filter which all reduce the amount of items to only show the best bargains. Don't let that stop you from making one, but there is usually not much left to filter once these 3 are applied with the correct settings.
I think the additional calls to GetTradingHouseSearchResultItemInfo are the lesser of two evils. If it is called 200 times instead of 100 times should not really make a difference overall. Changing the behavior of CreateItemData just makes the code more complicated and does not have any real benefit IMO.
2) Your hack looks really hackish. I guess it would need much more comments in order to make clear what it does.
Maybe just use function swapping instead.
One major problem with changing the local sort order is that the API uses the item index for purchasing, so we need to keep that information intact.
I would just do everything related to sorting in a swapped out ZO_ScrollList_Commit and leave the other methods alone.
The searchtab wrapper is already wrapping around that method twice and calls ZO_ScrollList_Commit a second time, so that should also be combine into one call with some added hook points.
And last but not least there was also the feature request from Tony to prevent the scroll list from resetting to top in some cases which would also go in there. (I haven't forgotten about that
)
Quite a few things that will go in there.
Maybe ZOS can add a few hook points to make it a bit easier?
Lua Code:
function ZO_TradingHouse_CreateItemData(index, fn, filter)
local icon, name, quality, stackCount, sellerName, timeRemaining, purchasePrice, currencyType = fn(index)
if(name ~= "" and stackCount > 0) then
if(type(filter) == "function" and filter(icon, name, quality, stackCount, sellerName, timeRemaining, purchasePrice, currencyType)) then
local result =
{
slotIndex = index,
icon = icon,
name = name,
quality = quality,
stackCount = stackCount,
sellerName = sellerName,
timeRemaining = timeRemaining,
purchasePrice = purchasePrice,
currencyType = currencyType or CURT_MONEY
}
return result
else
return true -- to indicate that it exists but was filtered
end
end
end
Lua Code:
function ZO_TradingHouseManager:RebuildSearchResultsPage(preventResetToTop)
local list = self.m_searchResultsList
local scrollData = ZO_ScrollList_GetDataList(list)
ZO_ScrollList_Clear(list)
if(not preventResetToTop) then ZO_ScrollList_ResetToTop(list) end
self:BeforeFilterSearchResultsPage()
local hiddenNumItems = 0
for i = 1, self.m_numItemsOnPage do
local result = ZO_TradingHouse_CreateItemData(i, GetTradingHouseSearchResultItemInfo, self.SearchResultFilterFunction) -- The default SearchResultFilterFunction just returns true and can be prehooked or wrapped by addons
if(result == true) then hiddenNumItems = hiddenNumItems + 1
elseif(result) then
scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(SEARCH_RESULTS_DATA_TYPE, result)
end
end
local numItems = #scrollData
local totalNumItems = hiddenNumItems + numItems
self:AfterFilterSearchResultsPage(totalNumItems, numItems)
self:UpdateItemsLabels(totalNumItems, numItems)
-- If no results were returned, disallow further searches (until one or more search criteria are modified),
-- and display a "no items found" label.
self.m_searchAllowed = (totalNumItems ~= 0)
self.m_noItemsLabel:SetHidden(totalNumItems ~= 0)
self:SortSearchResultsPage(scrollData)
ZO_ScrollList_Commit(list)
end
function ZO_TradingHouseManager:OnPurchaseSuccess()
self:RebuildSearchResultsPage(true)
end