-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.lua
More file actions
43 lines (38 loc) · 1.4 KB
/
Model.lua
File metadata and controls
43 lines (38 loc) · 1.4 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
local LibEvent = LibStub:GetLibrary("LibEvent.7000")
local addon = TinyTooltip
LibEvent:attachTrigger("tooltip:init", function(self, tip)
if (tip ~= GameTooltip) then return end
if (not tip.model) then
tip.model = CreateFrame("PlayerModel", nil, tip)
tip.model:SetSize(150, 150)
tip.model:SetFacing(-0.25)
tip.model:SetPoint("BOTTOMRIGHT", tip, "TOPRIGHT", 8, -16)
tip.model:Hide()
tip.model:SetScript("OnUpdate", function(self, elapsed)
if (IsControlKeyDown() or IsAltKeyDown()) then
self:SetFacing(self:GetFacing() + math.pi * elapsed)
end
end)
end
end)
LibEvent:attachTrigger("tooltip:unit", function(self, tip, unit)
if (tip ~= GameTooltip) then return end
if (not UnitIsVisible(unit)) then return end
if (addon.db.unit.player.showModel and UnitIsPlayer(unit)) then
tip.model:SetUnit(unit)
tip.model:SetFacing(-0.25)
tip.model:Show()
elseif (addon.db.unit.npc.showModel and not UnitIsPlayer(unit)) then
tip.model:SetUnit(unit)
tip.model:SetFacing(-0.25)
tip.model:Show()
else
tip.model:ClearModel()
tip.model:Hide()
end
end)
LibEvent:attachTrigger("tooltip:cleared", function(self, tip)
if (tip ~= GameTooltip) then return end
tip.model:ClearModel()
tip.model:Hide()
end)