forked from ascott18/Masque-Skinner-Blizz-Buffs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlizzBuffsFacade.lua
133 lines (114 loc) · 4.06 KB
/
BlizzBuffsFacade.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
local LMB = LibStub("Masque", true)
if not LMB then return end
local Buffs = LMB:Group("Blizzard Buffs", "Buffs")
local Debuffs = LMB:Group("Blizzard Buffs", "Debuffs")
if AuraButtonMixin then
-- Dragonflight+
local skinned = {}
local function makeHook(group, container)
local function updateFrames(frames)
for i = 1, #frames do
local frame = frames[i]
if not skinned[frame] then
skinned[frame] = 1
-- We have to make a wrapper to hold the skinnable components of the Icon
-- because the aura frames are not square (and so if we skinned them directly
-- with Masque, they'd get all distorted and weird).
local skinWrapper = CreateFrame("Frame")
skinWrapper:SetParent(frame)
skinWrapper:SetSize(30, 30)
skinWrapper:SetPoint("TOP")
-- Blizzard's code constantly tries to reposition the icon,
-- so we have to make our own icon that it won't try to move.
frame.Icon:Hide()
frame.SkinnedIcon = skinWrapper:CreateTexture(nil, "BACKGROUND")
frame.SkinnedIcon:SetSize(30, 30)
frame.SkinnedIcon:SetPoint("CENTER")
frame.SkinnedIcon:SetTexture(frame.Icon:GetTexture())
hooksecurefunc(frame.Icon, "SetTexture", function(_, tex)
frame.SkinnedIcon:SetTexture(tex)
end)
if frame.Count then
-- edit mode versions don't have stack text
frame.Count:SetParent(skinWrapper);
end
if frame.DebuffBorder then
frame.DebuffBorder:SetParent(skinWrapper);
end
if frame.TempEnchantBorder then
frame.TempEnchantBorder:SetParent(skinWrapper);
frame.TempEnchantBorder:SetVertexColor(.75, 0, 1)
end
if frame.Symbol then
-- Shows debuff types as text in colorblind mode (except it currently doesnt work)
frame.Symbol:SetParent(skinWrapper);
end
local bType = frame.auraType or "Aura"
if bType == "DeadlyDebuff" then
bType = "Debuff"
end
group:AddButton(skinWrapper, {
Icon = frame.SkinnedIcon,
DebuffBorder = frame.DebuffBorder,
EnchantBorder = frame.TempEnchantBorder,
Count = frame.Count,
HotKey = frame.Symbol
}, bType)
end
end
end
return function(self)
updateFrames(self.auraFrames, group)
if self.exampleAuraFrames then
updateFrames(self.exampleAuraFrames, group)
end
end
end
hooksecurefunc(BuffFrame, "UpdateAuraButtons", makeHook(Buffs, BuffFrame))
hooksecurefunc(BuffFrame, "OnEditModeEnter", makeHook(Buffs, BuffFrame))
hooksecurefunc(DebuffFrame, "UpdateAuraButtons", makeHook(Debuffs, DebuffFrame))
hooksecurefunc(DebuffFrame, "OnEditModeEnter", makeHook(Debuffs, DebuffFrame))
else
local f = CreateFrame("Frame")
local TempEnchant = LMB:Group("Blizzard Buffs", "TempEnchant")
local function NULL()
end
local function OnEvent(self, event, addon)
for i=1, BUFF_MAX_DISPLAY do
local buff = _G["BuffButton"..i]
if buff then
Buffs:AddButton(buff, nil, "Buff")
end
if not buff then break end
end
for i=1, BUFF_MAX_DISPLAY do
local debuff = _G["DebuffButton"..i]
if debuff then
Debuffs:AddButton(debuff, nil, "Debuff")
end
if not debuff then break end
end
for i=1, (NUM_TEMP_ENCHANT_FRAMES or 3) do
local f = _G["TempEnchant"..i]
--_G["TempEnchant"..i.."Border"].SetTexture = NULL
if TempEnchant then
TempEnchant:AddButton(f, nil, "Enchant")
end
_G["TempEnchant"..i.."Border"]:SetVertexColor(.75, 0, 1)
end
f:SetScript("OnEvent", nil)
end
hooksecurefunc("CreateFrame", function (_, name, parent) --dont need to do this for TempEnchant enchant frames because they are hard created in xml
if parent ~= BuffFrame or type(name) ~= "string" then return end
if strfind(name, "^DebuffButton%d+$") then
Debuffs:AddButton(_G[name], nil, "Debuff")
Debuffs:ReSkin() -- Needed to prevent issues with stack text appearing under the frame.
elseif strfind(name, "^BuffButton%d+$") then
Buffs:AddButton(_G[name], nil, "Buff")
Buffs:ReSkin() -- Needed to prevent issues with stack text appearing under the frame.
end
end
)
f:SetScript("OnEvent", OnEvent)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
end