View Single Post
11/23/15, 09:03 PM   #1
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
extending AwesomeGuildStore

This is primarily aimed at @sirinsidiator, I just wouldn't want to lose out on ideas others might suggest. Here are the two things I'm trying to do with AGS:
1) decile filter: cuts off results more expensive than N tenths of results on the current page (per item name); with N=5 the cut point is the median, so only the cheaper half of results will be shown.
2) sort results by name, then unit price -- will describe in another post

The decile filter needs to have all results before it starts filtering, so I gather them in f:BeforeRebuildSearchResultsPage, build a table of what should be kept, and f:FilterPageResult simply consults that table. It works well, but I'm still not completely comfortable with the fact that GetTradingHouseSearchResultItemInfo is called twice for each result -- first in my "Before" hook and then during the actual filtering. So I started thinking...

What if AGS' RebuildSearchResultsPage did:
- gather all ZO_TradingHouse_CreateItemData(i, GetTradingHouseSearchResultItemInfo) in a table
- pass that table to filters' PreprocessSearchResultsPage method -- this should not remove anything from the table
- replace ZO_TradingHouse_CreateItemData with a function that runs filters' FilterPageResultData and returns either data or nil

I'd like to know what you think because it has 2 quite big drawbacks so I'm not comfortable with that either:
- creating item data for all results; currently no table is created for results that are filtered out
- some ugly compatibility code:
Lua Code:
  1. function FilterBase:FilterPageResultData(data)
  2.     -- delegate to older method
  3.     return self:FilterPageResult(data.slotIndex, data.icon, data.name, data.quality, data.stackCount, data.sellerName, data.timeRemaining, data.purchasePrice, data.currencyType)
  4. end
  Reply With Quote