Commit 601c8c4a authored by Robin Schoonover's avatar Robin Schoonover

In quest log, handle currency reward types.

parent 3d5e4663
......@@ -5,5 +5,6 @@
## Author: End
## X-Email: end@cornhooves.org
AllTheIDs.lua
CurrencyCache.lua
GameTooltip.lua
Other.lua
local addon_name, addon = ...
local function defaulttable(callable)
callable = callable or function() return nil end
return setmetatable({}, {
__index = function(t, key)
local val = callable()
rawset(t, key, val)
return val
end
})
end
addon.currencyCache = defaulttable(defaulttable)
local event_frame = CreateFrame("FRAME")
event_frame:SetScript("OnEvent", function(frame, event, ...)
local func = frame[event]
if func then
return func(frame, ...)
end
end)
function event_frame:PLAYER_ENTERING_WORLD()
for idx = 1,GetCurrencyListSize() do
local link = GetCurrencyListLink(idx)
local name, _, _, _, _, _, icon = GetCurrencyListInfo(idx)
if name and icon then
addon.currencyCache[name][icon] = link
end
end
end
event_frame:RegisterEvent("PLAYER_ENTERING_WORLD")
event_frame:PLAYER_ENTERING_WORLD()
......@@ -107,12 +107,22 @@ addon:HookTip("SetMerchantCostItem", function(self, idx, currency)
addon:AddIDLine(self, "Currency", currencyID)
end)
addon:HookTip("SetQuestCurrency", function(self, type, idx)
-- TODO GetQuestCurrencyInfo(type, idx) => name, texture, count
addon:HookTip("SetQuestCurrency", function(tip, type, idx)
local name, icon = GetQuestCurrencyInfo(type, idx)
local link = addon.currencyCache[name][icon]
if link then
local _, _, name, id = strfind(link, "|H(%w+):(%d+)")
addon:AddIDLine(tip, name:gsub("^%l", string.upper), id)
end
end)
addon:HookTip("SetQuestLogCurrency", function(self, type, idx)
-- TODO GetQuestLogRewardCurrencyInfo(idx) => name, texture, count
addon:HookTip("SetQuestLogCurrency", function(tip, type, idx)
local name, icon = GetQuestLogRewardCurrencyInfo(idx)
local link = addon.currencyCache[name][icon]
if link then
local _, _, name, id = strfind(link, "|H(%w+):(%d+)")
addon:AddIDLine(tip, name:gsub("^%l", string.upper), id)
end
end)
addon:HookTip("SetQuestLogItem", function(self, ...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment