-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBaggins-Skins.lua
334 lines (273 loc) · 10.5 KB
/
Baggins-Skins.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
local Baggins = Baggins
local pairs, ipairs =
pairs, ipairs
local tinsert =
tinsert
local CreateColor = CreateColor
----------------
-- Skin stuff --
----------------
do -- private
local skins = {}
local skinlist = {}
local function void() end
function Baggins:GetSkinList() --luacheck: ignore 212
for k in pairs(skinlist) do
skinlist[k] = nil
end
for name in pairs(skins) do
tinsert(skinlist, name)
end
return skinlist
end
function Baggins:GetSkin(name) --luacheck: ignore 212
return skins[name]
end
function Baggins:RegisterSkin(name, skin)
skin.core = self
skin.name = skin.name or name
skin.SkinSection = skin.SkinSection or void
skin.SkinItem = skin.SkinItem or void
skin.SkinBag = skin.SkinBag or void
skin.UnskinSection = skin.UnskinSection or void
skin.UnskinItem = skin.UnskinItem or void
skin.UnskinBag = skin.UnskinBag or void
skins[name] = skin
end
end
function Baggins:DisableSkin(name)
local oldskin = self:GetSkin(name)
if oldskin and self.currentSkin == oldskin then
for _,bagframe in ipairs(self.bagframes) do
for _,sectionframe in ipairs(bagframe.sections) do
for _,itemframe in ipairs(sectionframe.items) do
oldskin:UnskinItem(itemframe)
end
oldskin:UnskinSection(sectionframe)
end
oldskin:UnskinBag(bagframe)
end
self.currentSkin = nil
end
end
function Baggins:EnableSkin(name)
local newskin = self:GetSkin(name)
if newskin and self.currentSkin ~= newskin then
for _,bagframe in ipairs(self.bagframes) do
for _,sectionframe in ipairs(bagframe.sections) do
for _,itemframe in ipairs(sectionframe.items) do
newskin:SkinItem(itemframe)
end
newskin:SkinSection(sectionframe)
sectionframe.dirty = true
end
newskin:SkinBag(bagframe)
bagframe.dirty = true
end
self.currentSkin = newskin
self:Baggins_RefreshBags()
end
end
function Baggins:ApplySkin(name)
if name ~= self.db.profile.skin and self:GetSkin(name) then
self:DisableSkin(self.db.profile.skin)
self.db.profile.skin = name
self:EnableSkin(name)
end
end
------------------
-- Default Skin --
------------------
local defaultSkin = {
BagLeftPadding = 10,
BagRightPadding = 10,
BagTopPadding = 32,
BagBottomPadding = 10,
TitlePadding = 32+48,
SectionTitleHeight = 13,
EmptySlotTexture = false,
BagFrameBackdrop = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 5, right = 5, top = 5, bottom = 5 }
},
NormalBagColor = 'black',
BankBagColor = 'blue',
}
function defaultSkin:SkinBag(frame)
frame:SetBackdrop(self.BagFrameBackdrop)
frame.closebutton:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
frame.compressbutton:ClearAllPoints();
frame.compressbutton:SetPoint("TOPRIGHT", frame.closebutton, "TOPLEFT", -4, -2);
frame.title:SetVertexColor(1,1,1,1)
frame.title:ClearAllPoints()
-- double anchoring is required to resize bag properly
frame.title:SetPoint("TOPLEFT",frame,"TOPLEFT",10,-10)
frame.title:SetPoint("RIGHT",frame.closebutton,"LEFT",0,0)
frame.title:SetHeight(12)
frame.title:SetJustifyH('LEFT')
end
function defaultSkin:SetBankVisual(frame, isBank)
local color = self.core.colors[self.NormalBagColor]
if isBank then
color = self.core.colors[self.BankBagColor]
end
frame:SetBackdropColor(color.r, color.g, color.b)
end
function defaultSkin:SkinSection(frame) --luacheck: ignore 212
frame.title:SetVertexColor(1,1,1,1)
frame.title:SetText("")
frame.title:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
frame.title:SetHeight(13)
end
Baggins:RegisterSkin('default', defaultSkin)
------------------------
-- Blizzard-like Skin --
------------------------
local blizzardSkin = setmetatable({
EmptySlotTexture = 'Interface\\AddOns\\Baggins\\Textures\\EmptySlot',
BagLeftPadding = 12,
BagRightPadding = 11,
BagTopPadding = 50,
BagBottomPadding = 11,
TitlePadding = 80,
BagFrameBackdrop = {
bgFile = 'Interface\\AddOns\\Baggins\\Textures\\AltBG',
edgeFile = 'Interface\\AddOns\\Baggins\\Textures\\BagFrameBorder',
tile = true, tileSize = 256, edgeSize = 32,
insets = { left = 7, right = 6, top = 7, bottom = 6 }
},
NormalBagColor = 'white',
}, {__index = defaultSkin}) -- inherits from defaultSkin
function blizzardSkin:SkinBag(frame)
frame:SetBackdrop(self.BagFrameBackdrop)
frame.closebutton:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-1)
frame.compressbutton:ClearAllPoints();
frame.compressbutton:SetPoint("TOPRIGHT", frame.closebutton, "BOTTOMRIGHT", -12, 8);
if not frame.portrait then
frame.portrait = frame:CreateTexture(frame:GetName().."Portrait","OVERLAY")
frame.portrait:SetWidth(48)
frame.portrait:SetHeight(48)
frame.portrait:SetPoint("TOPLEFT", frame, "TOPLEFT", -4, 0)
frame.portrait:SetTexture('Interface\\AddOns\\Baggins\\Textures\\BagFramePortraitFrame')
frame.portrait:SetTexCoord(0, 0.745, 0, 0.745)
end
frame.portrait:Show()
frame.title:ClearAllPoints()
frame.title:SetVertexColor(1,1,1,1)
-- double anchoring is required to resize bag properly
frame.title:SetPoint("LEFT",frame.portrait,"RIGHT",0,0)
frame.title:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-33,-9)
frame.title:SetHeight(12)
frame.title:SetJustifyH('RIGHT')
if not frame.icon then
frame.icon = frame:CreateTexture(frame:GetName().."Icon","ARTWORK")
frame.icon:SetWidth(34)
frame.icon:SetHeight(34)
frame.icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 3, -5)
frame.icon:SetTexture("Interface\\Icons\\INV_Jewelry_Ring_03")
end
frame.icon:Show()
end
function blizzardSkin:UnskinBag(frame) --luacheck: ignore 212
frame.portrait:Hide()
frame.icon:Hide()
end
function blizzardSkin:SetBankVisual(frame, isBank)
local color = self.core.colors[self.NormalBagColor]
if isBank then
color = self.core.colors[self.BankBagColor]
end
frame:SetBackdropColor(color.r, color.g, color.b)
frame:SetBackdropBorderColor(color.r, color.g, color.b)
frame.portrait:SetVertexColor(color.r, color.g, color.b)
end
Baggins:RegisterSkin('blizzard', blizzardSkin)
------------------------
-- oSkin-like Skin --
------------------------
local oSkin = setmetatable({}, {__index = defaultSkin}) -- inherits from defaultSkin
function oSkin:SkinBag(frame)
defaultSkin.SkinBag(self, frame) -- call inherited skinning
if not frame.tfade then
frame.tfade = frame:CreateTexture(nil, 'BORDER')
frame.tfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
frame.tfade:SetPoint('TOPLEFT', frame, 'TOPLEFT',1,-1)
frame.tfade:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT',-1,1)
frame.tfade:SetBlendMode('ADD')
--frame.tfade:SetGradient('VERTICAL', .1, .1, .1, 0, .2, .2, .2, 0.6)
if Baggins:IsRetailWow() or Baggins:IsWrathWow() then
frame.tfade:SetGradient("VERTICAL", CreateColor(0.1, 0.1, 0.1, 0), CreateColor(0.2, 0.2, 0.2, 0.6))
else
frame.tfade:SetGradient('VERTICAL', .1, .1, .1, 0, .2, .2, .2, 0.6)
end
frame.tfade:SetPoint('TOPLEFT', frame, 'TOPLEFT', 6, -6)
frame.tfade:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', -6, -30)
end
frame.tfade:Show()
end
function oSkin:UnskinBag(frame) --luacheck: ignore 212
frame.tfade:Hide()
end
Baggins:RegisterSkin('oSkin', oSkin)
------------------------
-- LSM Skins --
------------------------
local LibStub = LibStub
local LSM = LibStub:GetLibrary("LibSharedMedia-3.0", true) --luacheck:ignore 113
if LSM then
local backgrounds = LSM:List("background")
for _,v in pairs(backgrounds) do
local validatebackground = LSM:IsValid("background", v)
local validateborder = LSM:IsValid("border", v)
if validatebackground then
local background = LSM:Fetch("background", v)
local border
if not validateborder then
border = ""
end
if validateborder then
border = LSM:Fetch("border", v)
end
local LSMSkin = setmetatable({
EmptySlotTexture = background,
BagLeftPadding = 12,
BagRightPadding = 11,
BagTopPadding = 50,
BagBottomPadding = 11,
TitlePadding = 80,
BagFrameBackdrop = {
bgFile = background,
edgeFile = border,
tile = true, tileSize = 256, edgeSize = 0,
insets = { left = 7, right = 6, top = 7, bottom = 6 }
},
NormalBagColor = 'white',
}, {__index = defaultSkin}) -- inherits from defaultSkin
function LSMSkin:SkinBag(frame)
defaultSkin.SkinBag(self, frame) -- call inherited skinning
if not frame.tfade then
frame.tfade = frame:CreateTexture(nil, 'BORDER')
frame.tfade:SetTexture(background)
frame.tfade:SetPoint('TOPLEFT', frame, 'TOPLEFT',1,-1)
frame.tfade:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT',-1,1)
frame.tfade:SetBlendMode('ADD')
--frame.tfade:SetGradient('VERTICAL', .1, .1, .1, 0, .2, .2, .2, 0.6)
if Baggins:IsRetailWow() or Baggins:IsWrathWow()then
frame.tfade:SetGradient("VERTICAL", CreateColor(0.1, 0.1, 0.1, 0), CreateColor(0.2, 0.2, 0.2, 0.6))
else
frame.tfade:SetGradient('VERTICAL', .1, .1, .1, 0, .2, .2, .2, 0.6)
end
frame.tfade:SetPoint('TOPLEFT', frame, 'TOPLEFT', 6, -6)
frame.tfade:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', -6, -30)
end
frame.tfade:Show()
end
function LSMSkin:UnskinBag(frame) --luacheck: ignore 212
frame.tfade:Hide()
end
Baggins:RegisterSkin(v, LSMSkin)
end
end
end