Skip to content

Feature: don't display known recipes and unuseable stuff

Xyne edited this page Sep 13, 2010 · 1 revision

Hi,

Some short code reading and a few lines later I have the code proposal for my feature request, use as you like
( works fine for me so far, a keybinding or checkbox or option to switch between display all should be implemented )

see you xyne

— New function to generate Whitelist of items to display
local WHITELIST = {}
local _, _, _, _, _, _, _, _, RECIPE = GetAuctionItemClasses()
local function GetWhitelist()
for i=1, GetMerchantNumItems() do
local name, itemTexture, itemPrice, itemStackCount, numAvailable, isUsable, extendedCost = GetMerchantItemInfo(i)
if isUsable then
local link = GetMerchantItemLink(i)
if link then
local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link)
if not (class == RECIPE and knowns[link]) then
table.insert(WHITELIST, i)
end
end
end
end
end

— Changed OnShow, clear old Whitelist, generate new Whitelist, adjust scroll MinMaxValues
GVS:SetScript(“OnShow”, function()
WHITELIST = {}
GetWhitelist()
scrollbar:SetMinMaxValues(0, math.max(0, #WHITELISTNUMROWS ))
scrollbar:SetValue(0)
Refresh()
end)

— Changed Refresh, use WHITELIST[j] insted of j and adjust n
local function Refresh()
local n = #WHITELIST
for i,row in pairs(rows) do
local j = i + offset
if j > n then
row:Hide()
else
row.backdrop:Hide()

local name, itemTexture, itemPrice, itemStackCount, numAvailable, isUsable, extendedCost = GetMerchantItemInfo(WHITELIST[j])
local link = GetMerchantItemLink(WHITELIST[j])
local color = quality_colors.default
if link then
local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link)
color = quality_colors[quality]
end

row:SetAlpha(searchstring and not name:lower():match(searchstring) and 0.5 or 1)

row.icon:SetTexture(itemTexture)
row.ItemName:SetText((numAvailable > -1 and (“[”..numAvailable.."] ") or "").. color.. (name or “”).. (itemStackCount > 1 and (“|r x”..itemStackCount) or ""))

for i,v in pairs(row.altframes) do v:Hide() end
row.altcurrency = extendedCost
if extendedCost then
row:AddAltCurrency(WHITELIST[j])
row.link, row.texture, row.extendedCost = link, itemTexture, true
end
if itemPrice > 0 then
row.ItemPrice:SetText(GSC)
row.Price = itemPrice
end
if extendedCost and (itemPrice <= 0) then
row.ItemPrice:SetText()
row.Price = 0
elseif extendedCost and (itemPrice > 0) then
row.ItemPrice:SetText(GSC)
else
row.ItemName:SetPoint(“RIGHT”, row.ItemPrice, “LEFT”, -GAP, 0)
row.extendedCost = nil
end

if isUsable then row.icon:SetVertexColor(1, 1, 1) else row.icon:SetVertexColor(.9, 0, 0) end
row:SetID(WHITELIST[j])
row:Show()
end
end
end

Clone this wiki locally