Asa@89: local ItemAuditor = select(2, ...) Asa@89: local AuctionHouse = ItemAuditor:NewModule("AuctionHouse") Asa@89: Asa@89: local addon_options Asa@89: local function getAddons() Asa@89: -- this will ensure that the addons are only scanned once per session. Asa@89: if not addon_options then Asa@89: addon_options = {} Asa@89: local total = 0 Asa@89: local lastKey Asa@89: if AucAdvanced and AucAdvanced.Version then Asa@89: addon_options['auctioneer'] = 'Auctioneer' Asa@89: total = total + 1 Asa@89: lastKey = 'auctioneer' Asa@89: end Asa@89: if GetAuctionBuyout ~= nil then Asa@89: addon_options['other'] = 'Other (GetAuctionBuyout compatibile)' Asa@89: total = total + 1 Asa@89: lastKey = 'other' Asa@89: end Asa@89: Asa@89: if total == 1 or not ItemAuditor.db.profile.auction_addon then Asa@89: ItemAuditor.db.profile.auction_addon = lastKey Asa@89: end Asa@89: end Asa@89: Asa@89: return addon_options Asa@89: end Asa@89: Asa@89: local function getSelected() Asa@89: -- just making sure ItemAuditor.db.profile.auction_addon is set if there is only one addon Asa@89: if not addon_options then Asa@89: getAddons() Asa@89: end Asa@89: Asa@89: return ItemAuditor.db.profile.auction_addon Asa@89: end Asa@89: Asa@90: local function setAddon(info, value) Asa@90: ItemAuditor.db.profile.auction_addon = value Asa@90: end Asa@90: Asa@90: local function getPricingMethods() Asa@90: if ItemAuditor.db.profile.auction_addon == 'other' then Asa@90: return { Asa@90: low = 'Lowest Price', Asa@90: } Asa@90: else Asa@90: return { Asa@90: low = 'Lowest Price', Asa@90: market = 'Market Price', Asa@90: } Asa@90: end Asa@90: end Asa@90: Asa@89: ItemAuditor.Options.args.auction_house = { Asa@89: name = "Auction House", Asa@89: type = 'group', Asa@89: args = { Asa@89: ah_addon = { Asa@89: type = "select", Asa@89: name = "Addon", Asa@89: desc = "", Asa@89: values = getAddons, Asa@89: get = getSelected, Asa@90: set = setAddon, Asa@89: order = 0, Asa@89: }, Asa@90: pricingMethod = { Asa@90: type = "select", Asa@90: name = "Pricing Method", Asa@90: desc = "", Asa@90: values = getPricingMethods, Asa@90: get = function() return ItemAuditor.db.profile.pricing_method end, Asa@90: set = function(info, value) ItemAuditor.db.profile.pricing_method = value end, Asa@90: order = 1, Asa@90: } Asa@89: }, Asa@89: } Asa@89: Asa@89: function AuctionHouse:GetAuctionPrice(itemLink) Asa@89: local link = select(2, GetItemInfo(itemLink)) Asa@89: assert(link, 'Invalid item link: '..itemLink) Asa@89: local addon = getSelected() Asa@90: local prices = ItemAuditor.db.profile.pricing_method or 'low' Asa@89: if GetAuctionBuyout ~= nil and addon == 'other' then Asa@89: return GetAuctionBuyout(link) Asa@89: elseif AucAdvanced and AucAdvanced.Version and addon == 'auctioneer' then Asa@90: if prices == 'low' then Asa@90: local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(link) Asa@90: return lowBuy Asa@90: else Asa@90: return AucAdvanced.API.GetMarketValue(link) Asa@90: end Asa@89: end Asa@89: return nil Asa@89: end