Make qty text red for alt-currency that we don't have enough of

This commit is contained in:
tekkub 2011-02-27 23:37:17 -07:00
parent 7749d996e8
commit 2a0ac57311
1 changed files with 14 additions and 4 deletions

View File

@ -89,10 +89,20 @@ local function OnLeave()
end 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 SetValue(self, text, icon, link) local function SetValue(self, text, icon, link)
self.text:SetText(text) local color = link and GetCurencyCount(link) >= text and "|cffffffff" or "|cffff9999"
self.text:SetText(color..text)
self.icon:SetTexture(icon) self.icon:SetTexture(icon)
self.link, self.index, self.itemIndex = link self.link, self.index, self.itemIndex = nil
if link and link:match("^item:%d+") then self.link = link end
self:Show() self:Show()
end end
@ -129,8 +139,8 @@ local function AddAltCurrency(frame, i)
if ns.IHASCAT then itemCount, honorPoints, arenaPoints = honorPoints, 0, 0 end if ns.IHASCAT then itemCount, honorPoints, arenaPoints = honorPoints, 0, 0 end
for j=itemCount,1,-1 do for j=itemCount,1,-1 do
local f = frame:GetAltCurrencyFrame() local f = frame:GetAltCurrencyFrame()
local texture, price = GetMerchantItemCostItem(i, j) local texture, price, _, name = GetMerchantItemCostItem(i, j)
f:SetValue(price, texture) f:SetValue(price, texture, name)
f.index, f.itemIndex, f.link = i, j f.index, f.itemIndex, f.link = i, j
lastframe = f.text lastframe = f.text
end end