-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathItem.lua
47 lines (40 loc) · 1.61 KB
/
Item.lua
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
local LibEvent = LibStub:GetLibrary("LibEvent.7000")
local addon = TinyTooltip
local function ColorBorder(tip, r, g, b)
if (addon.db.item.coloredItemBorder) then
LibEvent:trigger("tooltip.style.border.color", tip, r, g, b)
else
LibEvent:trigger("tooltip.style.border.color", tip, unpack(addon.db.general.borderColor))
end
end
local function ItemIcon(tip, link)
if (addon.db.item.showItemIcon) then
local texture = select(10, GetItemInfo(link))
local text = addon:GetLine(tip,1):GetText()
if (texture and not strfind(text, "^|T")) then
addon:GetLine(tip,1):SetFormattedText("|T%s:16:16:0:0:32:32:2:30:2:30|t %s", texture, text)
end
end
end
local function ItemStackCount(tip, link)
if (addon.db.item.showStackCount) then
local stackCount = select(8, GetItemInfo(link))
if (stackCount and stackCount > 1) then
local text = addon:GetLine(tip,1):GetText() .. format(" |cff00eeee/%s|r", stackCount)
addon:GetLine(tip,1):SetText(text)
end
end
end
LibEvent:attachTrigger("tooltip:item", function(self, tip, link)
local quality = select(3, GetItemInfo(link)) or 0
local r, g, b = GetItemQualityColor(quality)
ColorBorder(tip, r, g, b)
ItemStackCount(tip, link)
ItemIcon(tip, link)
end)
hooksecurefunc("EmbeddedItemTooltip_OnTooltipSetItem", function(self)
local tip = self:GetParent()
if (not tip or tip:GetObjectType() ~= "GameTooltip") then return end
local r, g, b = self.IconBorder:GetVertexColor()
ColorBorder(tip, r, g, b)
end)