-
Notifications
You must be signed in to change notification settings - Fork 1
/
SkinSupport.lua
140 lines (117 loc) · 3.38 KB
/
SkinSupport.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
134
135
136
137
138
139
140
--[[--------------------------------------------------------------------
PhanxBuffs
Replacement player buff, debuff, and temporary enchant frames.
Copyright (c) 2010-2018 Phanx <[email protected]>. All rights reserved.
https://github.com/Phanx/PhanxBuffs
https://www.curseforge.com/wow/addons/phanxbuffs
https://www.wowinterface.com/downloads/info16874-PhanxBuffs.html
----------------------------------------------------------------------]]
local Masque = LibStub("Masque", true)
if not Masque then return end
local done
local _, ns = ...
function ns.SkinWithMasque()
-- print("Initializing skin support...")
if done then return end
local db = PhanxBuffsDB
if db.noMasque then return end
if db.skin then
-- print("Removing old skin data...")
db.skin = nil
end
local buttonDataLayers = {
"AutoCast",
"AutoCastable",
"Backdrop",
"Checked",
"Cooldown",
"Count",
"Disabled",
"Flash",
"Highlight",
"HotKey",
"Name",
"Pushed"
}
local function SkinButton(f)
-- print("Skinning button in frame " .. f:GetParent():GetName() .. "...")
if f.border then
f.border:SetTexture(nil)
f.border:Hide()
f.border = nil
end
f.buttonData = {
Icon = f.icon
}
for i = 1, #buttonDataLayers do
f.buttonData[buttonDataLayers[i]] = false
end
if f:GetParent() == PhanxBuffFrame then
f.buttonData.Border = false
else
f.border = f.border or f:CreateTexture()
f.buttonData.Border = f.border
end
if f.SetBorderColor then
f.SetBorderColor = function(f, r, g, b, a)
if a and a > 0 then
f.border:SetVertexColor(r, g, b, a)
else
f.border:SetVertexColor(1, 1, 1, 0)
end
end
end
Masque:Group("PhanxBuffs"):AddButton(f, f.buttonData)
if f:GetParent() == PhanxTempEnchantFrame then
-- print("Recoloring temp enchant button")
f.border:SetVertexColor(0.46, 0.18, 0.67, 1)
end
end
local function SkinFrame(frame)
-- print("Skinning frame " .. frame:GetName() .. "...")
local buttons = frame.buttons
for i = 1, #buttons do
-- print("Skinning button " .. i .. " in frame " .. frame:GetName() .. "...")
SkinButton(buttons[i])
end
local oldmetatable = getmetatable(buttons).__index
setmetatable(buttons, { __index = function(t, i)
local f = oldmetatable(t, i)
-- print("Creating skinned button in frame " .. f:GetParent():GetName() .. "...")
SkinButton(f)
return f
end })
end
local hooked
local function ReSkin(self)
local button = self.buttons[1]
if not button then return end
local size = floor(button:GetHeight() + 0.5)
if size ~= button.prevsize then
--print("reskinning on size change", button.prevsize, "=>", size)
button.prevsize = size
Masque:Group("PhanxBuffs"):ReSkin()
end
end
local function OnSkinChanged(_, _, skin, gloss, backdrop, colors, fonts)
-- print(string.format("New skin: %s, Gloss: %s, Backdrop: %s", skin, tostring(gloss), tostring(backdrop)))
for i = 1, #PhanxTempEnchantFrame.buttons do
-- print("Recoloring temp enchant button", i)
PhanxTempEnchantFrame.buttons[i].border:SetVertexColor(0.46, 0.18, 0.67, 1)
end
for i = 1, #ns.auraFrames do
ns.auraFrames[i]:Update()
end
if not hooked then
for i = 1, #ns.auraFrames do
hooksecurefunc(ns.auraFrames[i], "UpdateLayout", ReSkin)
end
hooked = true
end
end
Masque:Register("PhanxBuffs", OnSkinChanged)
for i = 1, #ns.auraFrames do
SkinFrame(ns.auraFrames[i])
end
done = true
end