-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathutils.lua
More file actions
58 lines (52 loc) · 1.79 KB
/
utils.lua
File metadata and controls
58 lines (52 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local _, addon = ...
if TooltipDataProcessor and C_TooltipInfo then
function addon:HookTooltip(callback)
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, function(tooltip, data)
if not (tooltip and not tooltip:IsForbidden() and tooltip:GetOwner()) then
return
end
if tooltip ~= GameTooltip then
-- disqualify shopping tooltips
return
end
if data.guid then
local location = C_Item.GetItemLocation(data.guid)
if location and location:IsBagAndSlot() then
local bagID = location:GetBagAndSlot()
if bagID >= 0 and bagID <= 5 then -- limit to player bags
callback(tooltip, Item:CreateFromItemLocation(location))
end
end
elseif tooltip:GetOwner():GetName() == 'TradeRecipientItem7ItemButton' then
-- special handling for trade window
local _, itemLink = tooltip:GetItem()
if itemLink then
callback(tooltip, Item:CreateFromItemLink(itemLink))
end
end
end)
end
else
function addon:HookTooltip(callback)
hooksecurefunc(GameTooltip, 'SetBagItem', function(tooltip, bagID, slotID)
if not (tooltip and not tooltip:IsForbidden() and tooltip:GetOwner()) then
return
end
local _, itemLink = tooltip:GetItem()
if itemLink then
if bagID and slotID and bagID >= 0 and bagID <= 4 then -- limit to player bags
callback(tooltip, Item:CreateFromItemLocation(ItemLocation:CreateFromBagAndSlot(bagID, slotID)))
end
end
end)
hooksecurefunc(GameTooltip, 'SetTradeTargetItem', function(tooltip)
if not (tooltip and not tooltip:IsForbidden() and tooltip:GetOwner()) then
return
end
local _, itemLink = tooltip:GetItem()
if itemLink and tooltip:GetOwner():GetName() == 'TradeRecipientItem7ItemButton' then
callback(tooltip, Item:CreateFromItemLink(itemLink))
end
end)
end
end