/
local nameToID = {} -- maps localized currency names to IDs |
local function debug(str, ...) |
local f = DEBUG_CHAT_FRAME or ChatFrame3 |
f:AddMessage("|cffff9f7fExonumist:|r " .. strjoin(" ", tostringall(str, ...))) |
end |
------------------------------------------------------------------------ |
local collapsed, scanning = {} |
local function UpdateData() |
if scanning then return end |
--debug("UpdateData") |
--print("UpdateData") |
scanning = true |
local i, limit = 1, GetCurrencyListSize() |
while i <= limit do |
local link = GetCurrencyListLink(i) |
local id = tonumber(strmatch(link, "currency:(%d+)")) |
nameToID[name] = id |
--debug(name, "=>", id) |
--print(name, "=>", id) |
if count > 0 then |
charDB[id] = count |
else |
local function AddTooltipInfo(tooltip, currency, includePlayer) |
if not currency then return end |
--debug("AddTooltipInfo", currency, includePlayer) |
--print("AddTooltipInfo", currency, includePlayer) |
local spaced |
for i = (includePlayer and 1 or 2), #playerList do |
local name = playerList[i] |
UpdateData() |
hooksecurefunc(GameTooltip, "SetCurrencyByID", function(tooltip, id) |
--debug("SetCurrencyByID", id) |
--print("SetCurrencyByID", id) |
AddTooltipInfo(tooltip, id, not MerchantMoneyInset:IsMouseOver()) |
end) |
hooksecurefunc(GameTooltip, "SetCurrencyToken", function(tooltip, i) |
--debug("SetCurrencyToken", i) |
--print("SetCurrencyToken", i) |
local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i) |
AddTooltipInfo(tooltip, nameToID[name], not TokenFrame:IsMouseOver()) |
end) |
hooksecurefunc(GameTooltip, "SetHyperlink", function(tooltip, link) |
--debug("SetHyperlink", link) |
--print("SetHyperlink", link) |
local id = strmatch(link, "currency:(%d+)") |
if id then |
AddTooltipInfo(tooltip, tonumber(id), true) |
end) |
hooksecurefunc(ItemRefTooltip, "SetHyperlink", function(tooltip, link) |
--debug("SetHyperlink", link) |
--print("SetHyperlink", link) |
local id = strmatch(link, "currency:(%d+)") |
if id then |
AddTooltipInfo(tooltip, tonumber(id), true) |
---------------------- |
hooksecurefunc(GameTooltip, "SetMerchantCostItem", function(tooltip, item, currency) |
--debug("SetMerchantCostItem", item, currency) |
--print("SetMerchantCostItem", item, currency) |
local icon, _, _, name = GetMerchantItemCostItem(item, currency) |
AddTooltipInfo(tooltip, nameToID[name], true) |
end) |
------------------------------ |
hooksecurefunc(GameTooltip, "SetLFGDungeonReward", function(tooltip, dungeonID, rewardIndex) |
--debug("SetLFGDungeonReward", dungeonID, rewardIndex) |
--print("SetLFGDungeonReward", dungeonID, rewardIndex) |
local name = GetLFGDungeonRewardInfo(dungeonID, rewardIndex) |
if name then |
AddTooltipInfo(tooltip, nameToID[name], true) |
end) |
hooksecurefunc(GameTooltip, "SetLFGDungeonShortageReward", function(tooltip, dungeonID, shortageIndex, rewardIndex) |
--debug("SetLFGDungeonShortageReward", dungeonID, shortageIndex, rewardIndex) |
--print("SetLFGDungeonShortageReward", dungeonID, shortageIndex, rewardIndex) |
local name = GetLFGDungeonShortageRewardInfo(dungeonID, shortageIndex, rewardIndex) |
if name then |
AddTooltipInfo(tooltip, nameToID[name], true) |
hooksecurefunc(GameTooltip, "SetQuestCurrency", function(tooltip, type, id) |
local name = GetQuestCurrencyInfo(type, id) |
--debug("SetQuestCurrency", type, id, name) |
--print("SetQuestCurrency", type, id, name) |
if name then |
AddTooltipInfo(tooltip, nameToID[name], true) |
end |
end) |
hooksecurefunc(GameTooltip, "SetQuestLogCurrency", function(tooltip, type, id) |
--debug("SetQuestLogCurrency", type, id) |
--print("SetQuestLogCurrency", type, id) |
local name = GetQuestLogRewardCurrencyInfo(id) |
if name then |
AddTooltipInfo(tooltip, nameToID[name], true) |
end |
end) |
----------------- |
-- xMerchant |
----------------- |
if xMerchantFrame then |
local function xMerchantTooltip(self) |
--debug("xMerchant", self.pointType, self.itemLink) |
if self.pointType == "Beta" then |
local id = nameToID[self.itemLink] |
--debug("Found currency:", id) |
if id then |
self.UpdateTooltip = nil |
return GameTooltip:SetCurrencyByID(id) |
end |
end |
self.UpdateTooltip = self.origUpdateTooltip |
end |
for i = 1, 10 do |
for j = 1, MAX_ITEM_COST do |
local item = _G["xMerchantFrame"..i.."Item"..j] |
item:HookScript("OnEnter", xMerchantTooltip) |
item.origUpdateTooltip = item.UpdateTooltip |
end |
end |
end |
elseif event == "PLAYER_LOGOUT" then |
UpdateData() |
end |