integrate LibItemSearch into GnomishVendorShrinker and hide items which do not match the search
This commit is contained in:
parent
36c265a5e1
commit
687717f325
|
@ -0,0 +1,6 @@
|
||||||
|
[submodule "libs/LibItemSearch-1.0"]
|
||||||
|
path = libs/LibItemSearch-1.0
|
||||||
|
url = git@github.com:Tuller/LibItemSearch-1.0.git
|
||||||
|
[submodule "libs/LibStub"]
|
||||||
|
path = libs/LibStub
|
||||||
|
url = git://github.com/p3lim/LibStub.git
|
|
@ -1,4 +1,4 @@
|
||||||
|
local ItemSearch = LibStub('LibItemSearch-1.0')
|
||||||
local myname, ns = ...
|
local myname, ns = ...
|
||||||
ns.IHASCAT = select(4, GetBuildInfo()) >= 40000
|
ns.IHASCAT = select(4, GetBuildInfo()) >= 40000
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ local rows = {}
|
||||||
for i=1,NUMROWS do
|
for i=1,NUMROWS do
|
||||||
local row = CreateFrame('Button', nil, GVS) -- base frame
|
local row = CreateFrame('Button', nil, GVS) -- base frame
|
||||||
row:SetHeight(ROWHEIGHT)
|
row:SetHeight(ROWHEIGHT)
|
||||||
row:SetPoint("TOP", i == 1 and GVS or rows[i-1], i == 1 and "TOP" or "BOTTOM")
|
|
||||||
row:SetPoint("LEFT")
|
row:SetPoint("LEFT")
|
||||||
row:SetPoint("RIGHT", -19, 0)
|
row:SetPoint("RIGHT", -19, 0)
|
||||||
|
|
||||||
|
@ -247,23 +246,16 @@ local grads = setmetatable({
|
||||||
[4] = {1,0,1,0.75, 1,0,1,0}, -- purple
|
[4] = {1,0,1,0.75, 1,0,1,0}, -- purple
|
||||||
[7] = {1,.75,.5,0.75, 1,.75,.5,0}, -- heirloom
|
[7] = {1,.75,.5,0.75, 1,.75,.5,0}, -- heirloom
|
||||||
}, {__index = function(t,i) t[i] = default_grad return default_grad end})
|
}, {__index = function(t,i) t[i] = default_grad return default_grad end})
|
||||||
local _, _, _, _, _, _, RECIPE = GetAuctionItemClasses()
|
local RECIPE = select(7, GetAuctionItemClasses())
|
||||||
local quality_colors = setmetatable({}, {__index = function() return "|cffffffff" end})
|
local quality_colors = setmetatable({}, {__index = function() return "|cffffffff" end})
|
||||||
for i=1,7 do quality_colors[i] = select(4, GetItemQualityColor(i)) end
|
for i=1,7 do quality_colors[i] = select(4, GetItemQualityColor(i)) end
|
||||||
local offset = 0
|
|
||||||
local searchstring
|
|
||||||
local function Refresh()
|
|
||||||
local n = GetMerchantNumItems()
|
|
||||||
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(j)
|
local ShowMerchantItem = function (r, i)
|
||||||
local link = GetMerchantItemLink(j)
|
local name, itemTexture, itemPrice, itemStackCount, numAvailable, isUsable, extendedCost = GetMerchantItemInfo(i)
|
||||||
|
local link = GetMerchantItemLink(i)
|
||||||
local color = quality_colors.default
|
local color = quality_colors.default
|
||||||
|
local row = rows[r]
|
||||||
|
row.backdrop:Hide()
|
||||||
if link then
|
if link then
|
||||||
local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link)
|
local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link)
|
||||||
color = quality_colors[quality]
|
color = quality_colors[quality]
|
||||||
|
@ -279,15 +271,13 @@ local function Refresh()
|
||||||
row.backdrop:Show()
|
row.backdrop:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
row:SetAlpha(searchstring and name and not name:lower():match(searchstring) and 0.5 or 1)
|
|
||||||
|
|
||||||
row.icon:SetTexture(itemTexture)
|
row.icon:SetTexture(itemTexture)
|
||||||
row.ItemName:SetText((numAvailable > -1 and ("["..numAvailable.."] ") or "").. color.. (name or "<Loading item data>").. (itemStackCount > 1 and ("|r x"..itemStackCount) or ""))
|
row.ItemName:SetText((numAvailable > -1 and ("["..numAvailable.."] ") or "").. color.. (name or "<Loading item data>").. (itemStackCount > 1 and ("|r x"..itemStackCount) or ""))
|
||||||
|
|
||||||
for i,v in pairs(row.altframes) do v:Hide() end
|
for i,v in pairs(row.altframes) do v:Hide() end
|
||||||
row.altcurrency = extendedCost
|
row.altcurrency = extendedCost
|
||||||
if extendedCost then
|
if extendedCost then
|
||||||
row:AddAltCurrency(j)
|
row:AddAltCurrency(i)
|
||||||
row.link, row.texture, row.extendedCost = link, itemTexture, true
|
row.link, row.texture, row.extendedCost = link, itemTexture, true
|
||||||
end
|
end
|
||||||
if itemPrice > 0 then
|
if itemPrice > 0 then
|
||||||
|
@ -305,12 +295,33 @@ local function Refresh()
|
||||||
end
|
end
|
||||||
|
|
||||||
if isUsable then row.icon:SetVertexColor(1, 1, 1) else row.icon:SetVertexColor(.9, 0, 0) end
|
if isUsable then row.icon:SetVertexColor(1, 1, 1) else row.icon:SetVertexColor(.9, 0, 0) end
|
||||||
row:SetID(j)
|
row:SetID(i)
|
||||||
row:Show()
|
row:Show()
|
||||||
end
|
row:SetPoint("TOP", r == 1 and GVS or rows[r-1], r == 1 and "TOP" or "BOTTOM")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local scrollbar = LibStub("tekKonfig-Scroll").new(GVS, 0, SCROLLSTEP)
|
||||||
|
local offset = 0
|
||||||
|
local searchstring
|
||||||
|
local function Refresh()
|
||||||
|
local n = GetMerchantNumItems()
|
||||||
|
local r = 1
|
||||||
|
local v = 0
|
||||||
|
for i=1,n do
|
||||||
|
local link = GetMerchantItemLink(i)
|
||||||
|
if ItemSearch:Find(link, searchstring) then
|
||||||
|
if v >= offset and v < offset + NUMROWS then
|
||||||
|
ShowMerchantItem(r, i)
|
||||||
|
r = r + 1
|
||||||
|
end
|
||||||
|
v = v + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
scrollbar:SetMinMaxValues(0, math.max(0, v - NUMROWS))
|
||||||
|
for i=r,NUMROWS do
|
||||||
|
rows[i]:Hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local editbox = CreateFrame('EditBox', nil, GVS)
|
local editbox = CreateFrame('EditBox', nil, GVS)
|
||||||
editbox:SetAutoFocus(false)
|
editbox:SetAutoFocus(false)
|
||||||
|
@ -362,7 +373,6 @@ editbox:SetScript("OnShow", function(self)
|
||||||
self:SetTextColor(0.75, 0.75, 0.75, 1)
|
self:SetTextColor(0.75, 0.75, 0.75, 1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local scrollbar = LibStub("tekKonfig-Scroll").new(GVS, 0, SCROLLSTEP)
|
|
||||||
local f = scrollbar:GetScript("OnValueChanged")
|
local f = scrollbar:GetScript("OnValueChanged")
|
||||||
scrollbar:SetScript("OnValueChanged", function(self, value, ...)
|
scrollbar:SetScript("OnValueChanged", function(self, value, ...)
|
||||||
offset = math.floor(value)
|
offset = math.floor(value)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||||
|
<Script file="libs\LibStub\LibStub.lua"/>
|
||||||
|
<Script file="libs\LibItemSearch-1.0\LibItemSearch-1.0.lua"/>
|
||||||
|
</Ui>
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ccbc28bfd62519fa4fe584739a83e33307a67853
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ed93b036659fd975d5137b24af276b487e8b017e
|
Loading…
Reference in New Issue