View Single Post
11/24/15, 07:11 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,580
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:
  1. function ZO_TradingHouse_CreateItemData(index, fn, filter)
  2.     local icon, name, quality, stackCount, sellerName, timeRemaining, purchasePrice, currencyType = fn(index)
  3.     if(name ~= "" and stackCount > 0) then
  4.       if(type(filter) == "function" and filter(icon, name, quality, stackCount, sellerName, timeRemaining, purchasePrice, currencyType)) then
  5.         local result =
  6.         {
  7.             slotIndex = index,
  8.             icon = icon,
  9.             name = name,
  10.             quality = quality,
  11.             stackCount = stackCount,
  12.             sellerName = sellerName,
  13.             timeRemaining = timeRemaining,
  14.             purchasePrice = purchasePrice,
  15.             currencyType = currencyType or CURT_MONEY
  16.         }
  17.  
  18.         return result
  19.       else
  20.         return true -- to indicate that it exists but was filtered
  21.       end
  22.     end
  23. end

Lua Code:
  1. function ZO_TradingHouseManager:RebuildSearchResultsPage(preventResetToTop)
  2.     local list = self.m_searchResultsList
  3.     local scrollData = ZO_ScrollList_GetDataList(list)
  4.     ZO_ScrollList_Clear(list)
  5.     if(not preventResetToTop) then ZO_ScrollList_ResetToTop(list) end
  6.  
  7.     self:BeforeFilterSearchResultsPage()
  8.     local hiddenNumItems = 0
  9.     for i = 1, self.m_numItemsOnPage do
  10.         local result = ZO_TradingHouse_CreateItemData(i, GetTradingHouseSearchResultItemInfo, self.SearchResultFilterFunction) -- The default SearchResultFilterFunction just returns true and can be prehooked or wrapped by addons
  11.         if(result == true) then hiddenNumItems = hiddenNumItems + 1
  12.         elseif(result) then
  13.             scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(SEARCH_RESULTS_DATA_TYPE, result)
  14.         end
  15.     end
  16.  
  17.     local numItems = #scrollData
  18.     local totalNumItems = hiddenNumItems + numItems
  19.     self:AfterFilterSearchResultsPage(totalNumItems, numItems)
  20.     self:UpdateItemsLabels(totalNumItems, numItems)
  21.  
  22.     -- If no results were returned, disallow further searches (until one or more search criteria are modified),
  23.     -- and display a "no items found" label.
  24.     self.m_searchAllowed = (totalNumItems ~= 0)
  25.     self.m_noItemsLabel:SetHidden(totalNumItems ~= 0)
  26.  
  27.     self:SortSearchResultsPage(scrollData)
  28.     ZO_ScrollList_Commit(list)
  29. end
  30.  
  31. function ZO_TradingHouseManager:OnPurchaseSuccess()
  32.     self:RebuildSearchResultsPage(true)
  33. end
  Reply With Quote