You've already forked GnomishVendorShrinker
Move those into a folder
This commit is contained in:
48
frames/AltCurrency.lua
Normal file
48
frames/AltCurrency.lua
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
local myname, ns = ...
|
||||
|
||||
|
||||
local function NewItemFrame(self, i)
|
||||
local item = ns.NewAltCurrencyItemFrame(self.parent)
|
||||
|
||||
if i == 1 then
|
||||
item:SetPoint("LEFT")
|
||||
else
|
||||
item:SetPoint("LEFT", self[i-1], "RIGHT")
|
||||
end
|
||||
|
||||
self[i] = item
|
||||
return item
|
||||
end
|
||||
|
||||
|
||||
local itemframesets = {}
|
||||
local function SetValue(self, i)
|
||||
local items = itemframesets[self]
|
||||
for _,item in ipairs(items) do item:Hide() end
|
||||
|
||||
local num = GetMerchantItemCostInfo(i)
|
||||
self:SetShown(num > 0)
|
||||
|
||||
if num > 0 then
|
||||
for j=1,num do items[j]:SetValue(i, j) end
|
||||
self:SizeToFit()
|
||||
else
|
||||
self:SetWidth(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local frames = {}
|
||||
local MT = {__index = NewItemFrame}
|
||||
function ns.NewAltCurrencyFrame(parent)
|
||||
local frame = CreateFrame("Frame", nil, parent)
|
||||
frame:SetSize(1,1)
|
||||
|
||||
itemframesets[frame] = setmetatable({parent = frame}, MT)
|
||||
|
||||
frame.SetValue = SetValue
|
||||
frame.SizeToFit = ns.SizeToFit
|
||||
|
||||
return frame
|
||||
end
|
76
frames/AltCurrencyItem.lua
Normal file
76
frames/AltCurrencyItem.lua
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
local myname, ns = ...
|
||||
|
||||
|
||||
local ICONSIZE, PADDING = 17, 2
|
||||
local icons, texts = {}, {}
|
||||
local indexes, ids = {}, {}
|
||||
|
||||
|
||||
local function OnEnter(self)
|
||||
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||
GameTooltip:SetMerchantCostItem(indexes[self], ids[self])
|
||||
end
|
||||
|
||||
|
||||
local function OnLeave()
|
||||
GameTooltip:Hide()
|
||||
ResetCursor()
|
||||
end
|
||||
|
||||
|
||||
local function GetCurencyCount(item)
|
||||
for i=1,GetCurrencyListSize() do
|
||||
local name, _, _, _, _, count = GetCurrencyListInfo(i)
|
||||
if item == name then return count end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function GetQtyOwned(item)
|
||||
local id = ns.ids[item]
|
||||
if id then return GetItemCount(id, true) or 0 end
|
||||
|
||||
return GetCurencyCount(item) or 0
|
||||
end
|
||||
|
||||
|
||||
local function GetTextColor(price, link)
|
||||
if link and (GetQtyOwned(link) < price) then return "|cffff9999" end
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
local function SetValue(self, i, j)
|
||||
indexes[self], ids[self] = i, j
|
||||
|
||||
local texture, price, link, name = GetMerchantItemCostItem(i, j)
|
||||
icons[self]:SetTexture(texture)
|
||||
texts[self]:SetText(GetTextColor(price, (link or name)).. price)
|
||||
|
||||
self:Show()
|
||||
end
|
||||
|
||||
|
||||
function ns.NewAltCurrencyItemFrame(parent)
|
||||
local frame = CreateFrame("Frame", nil, parent)
|
||||
frame:SetSize(ICONSIZE, ICONSIZE)
|
||||
|
||||
local text = frame:CreateFontString(nil, nil, "NumberFontNormalSmall")
|
||||
text:SetPoint("LEFT")
|
||||
texts[frame] = text
|
||||
|
||||
local icon = frame:CreateTexture()
|
||||
icon:SetSize(ICONSIZE, ICONSIZE)
|
||||
icon:SetPoint("LEFT", text, "RIGHT", PADDING, 0)
|
||||
icons[frame] = icon
|
||||
|
||||
frame.SetValue = SetValue
|
||||
frame.SizeToFit = ns.SizeToFit
|
||||
|
||||
frame:EnableMouse(true)
|
||||
frame:SetScript("OnEnter", OnEnter)
|
||||
frame:SetScript("OnLeave", OnLeave)
|
||||
|
||||
return frame
|
||||
end
|
95
frames/RowShader.lua
Normal file
95
frames/RowShader.lua
Normal file
@ -0,0 +1,95 @@
|
||||
|
||||
local myname, ns = ...
|
||||
|
||||
|
||||
|
||||
local RECIPE = GetItemClassInfo(LE_ITEM_CLASS_RECIPE)
|
||||
local MISC = GetItemClassInfo(LE_ITEM_CLASS_MISCELLANEOUS)
|
||||
local GARRISON_ICONS = {[1001489] = true, [1001490] = true, [1001491] = true}
|
||||
|
||||
|
||||
local function Knowable(link)
|
||||
local id = ns.ids[link]
|
||||
if C_Heirloom.IsItemHeirloom(id) then return true end
|
||||
|
||||
local _, _, _, _, _, class, _, _, _, texture = GetItemInfo(link)
|
||||
if class == MISC and select(2, C_ToyBox.GetToyInfo(id)) then return true end
|
||||
if class == RECIPE or GARRISON_ICONS[texture] then return true end
|
||||
end
|
||||
|
||||
|
||||
local function RecipeNeedsRank(link)
|
||||
local _, _, _, _, _, class = GetItemInfo(link)
|
||||
if class ~= RECIPE then return end
|
||||
return ns.unmet_requirements[link]
|
||||
end
|
||||
|
||||
|
||||
local DEFAULT_GRAD = {0,1,0,0.75, 0,1,0,0} -- green
|
||||
local GRADS = {
|
||||
red = {1,0,0,0.75, 1,0,0,0},
|
||||
[1] = {1,1,1,0.75, 1,1,1,0}, -- white
|
||||
[2] = DEFAULT_GRAD, -- green
|
||||
[3] = {0.5,0.5,1,1, 0,0,1,0}, -- blue
|
||||
[4] = {1,0,1,0.75, 1,0,1,0}, -- purple
|
||||
[7] = {1,.75,.5,0.75, 1,.75,.5,0}, -- heirloom
|
||||
}
|
||||
GRADS = setmetatable(GRADS, {
|
||||
__index = function(t,i)
|
||||
t[i] = DEFAULT_GRAD
|
||||
return DEFAULT_GRAD
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
function ns.GetRowGradient(index)
|
||||
local gradient = DEFAULT_GRAD
|
||||
local shown = false
|
||||
|
||||
local _, _, _, _, _, isUsable = GetMerchantItemInfo(index)
|
||||
if not isUsable then
|
||||
gradient = GRADS.red
|
||||
shown = true
|
||||
end
|
||||
|
||||
local link = GetMerchantItemLink(index)
|
||||
if not (link and Knowable(link)) then return gradient, shown end
|
||||
|
||||
if ns.knowns[link] then
|
||||
return gradient, false
|
||||
elseif RecipeNeedsRank(link) then
|
||||
return GRADS.red, true
|
||||
else
|
||||
return GRADS[quality], true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local QUALITY_COLORS = setmetatable({}, {
|
||||
__index = function(t,i)
|
||||
-- GetItemQualityColor only takes numbers, so fall back to white
|
||||
local _, _, _, hex = GetItemQualityColor(tonumber(i) or 1)
|
||||
t[i] = "|c".. hex
|
||||
return "|c".. hex
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
function ns.GetRowTextColor(index)
|
||||
local link = GetMerchantItemLink(index)
|
||||
if not link then return QUALITY_COLORS.default end
|
||||
|
||||
-- Grey out if already known
|
||||
if Knowable(link) and ns.knowns[link] then return QUALITY_COLORS[0] end
|
||||
|
||||
local _, _, quality = GetItemInfo(link)
|
||||
return QUALITY_COLORS[quality]
|
||||
end
|
||||
|
||||
|
||||
function ns.GetRowVertexColor(index)
|
||||
local _, _, _, _, _, isUsable = GetMerchantItemInfo(index)
|
||||
if isUsable then return 1.0, 1.0, 1.0
|
||||
else return 0.9, 0.0, 0.0
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user