-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrame.lua
392 lines (326 loc) · 11.3 KB
/
Frame.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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
local addonName, ns = ...
function NugPlateAuras:CreateMirrorButton(parent, db, index)
local db = NugPlateAurasDB
local mirror = CreateFrame("Button", parent:GetName().."AuraFrame"..index, parent, "ActionButtonTemplate")
mirror:SetHeight(db.auraSize)
mirror:SetWidth(db.auraSize)
if ns.MasqueGroup then
ns.MasqueGroup:AddButton(mirror)
end
mirror:Show()
local cd = mirror.cooldown
cd:SetReverse(true)
cd:SetDrawEdge(false)
mirror:EnableMouse(false)
mirror:Show()
return mirror
end
local MakeBorder = function(self, tex, left, right, top, bottom, level)
local t = self:CreateTexture(nil,"BORDER",nil,level)
t:SetTexture(tex)
t:SetPoint("TOPLEFT", self, "TOPLEFT", left, -top)
t:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -right, bottom)
return t
end
function NugPlateAuras:CreateSimpleButton(parent, db, index)
local f = CreateFrame("Frame", parent:GetName().."AuraFrame"..index, parent)
f:SetWidth(db.auraSize); f:SetHeight(db.auraSize)
local blackLayer = MakeBorder(f, "Interface\\BUTTONS\\WHITE8X8", 0, 0, 0, 0, -2)
blackLayer:SetVertexColor(0,0,0,0.4)
blackLayer:SetDrawLayer("ARTWORK", -2)
local border = 1
local tex = f:CreateTexture(nil,"ARTWORK")
f.icon = tex
tex:SetTexCoord(0.07, 0.93, 0.07, 0.93)
tex:SetPoint("TOPLEFT", f, "TOPLEFT", border, -border)
tex:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -border, border)
local cd = CreateFrame("Cooldown", nil, f, "CooldownFrameTemplate")
f.cooldown = cd
-- cd.noCooldownCount = true -- disable OmniCC for this cooldown
-- cd:SetHideCountdownNumbers(true)
cd:SetReverse(true)
cd:SetDrawEdge(false)
cd:SetPoint("TOPLEFT", border, -border)
cd:SetPoint("BOTTOMRIGHT", -border, border)
local stackframe = CreateFrame("Frame", nil, f)
stackframe:SetAllPoints(f)
local stacktext = stackframe:CreateFontString(nil,"ARTWORK")
stacktext:SetDrawLayer("ARTWORK",1)
stacktext:SetJustifyH"RIGHT"
stacktext:SetPoint("BOTTOMRIGHT", stackframe, "BOTTOMRIGHT", 0,0)
stacktext:SetTextColor(1,1,1)
stacktext:SetFontObject("NumberFontNormal")
f.stacktext = stacktext
return f
end
function NugPlateAuras:CreateProgressButton(parent, index)
local db = NugPlateAurasDB
local f = CreateFrame("Frame", parent:GetName().."AuraFrame"..index, parent)
local border = 2.5
f:SetWidth(db.auraSize-border); f:SetHeight(db.auraSize-border)
local blackLayer = MakeBorder(f, "Interface\\BUTTONS\\WHITE8X8", 0, 0, 0, 0, -2)
blackLayer:SetVertexColor(0,0,0,0.4)
blackLayer:SetDrawLayer("ARTWORK", 2)
local cd = CreateFrame("Cooldown", nil, f, "CooldownFrameTemplate")
f.cooldown = cd
-- cd.noCooldownCount = true -- disable OmniCC for this cooldown
-- cd:SetHideCountdownNumbers(true)
-- cd:SetReverse(true)
cd:SetDrawEdge(false)
local offset = 1
cd:SetPoint("TOPLEFT", offset, -offset)
cd:SetPoint("BOTTOMRIGHT", -offset, offset)
cd:SetScript("OnCooldownDone", function(self)
self:GetParent():Hide()
end)
cd:SetSwipeColor(0.8, 1, 0.2, 1);
cd:SetSwipeTexture("Interface\\BUTTONS\\WHITE8X8")
local tex = f:CreateTexture(nil,"ARTWORK")
f.icon = tex
tex:SetTexCoord(0.07, 0.93, 0.07, 0.93)
tex:SetPoint("TOPLEFT", f, "TOPLEFT", border, -border)
tex:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -border, border)
local iconSubFrame = CreateFrame("Frame", nil, f)
iconSubFrame:SetAllPoints(f)
iconSubFrame:SetFrameLevel(8)
tex:SetParent(iconSubFrame)
tex:SetDrawLayer("ARTWORK", 5)
-- local stackframe = CreateFrame("Frame", nil, f)
-- stackframe:SetAllPoints(f)
-- local stacktext = stackframe:CreateFontString(nil,"ARTWORK")
-- stacktext:SetDrawLayer("ARTWORK",1)
-- local stackFont = LSM:Fetch("font", Aptechka.db.nameFontName)
-- local stackFontSize = Aptechka.db.stackFontSize
-- stacktext:SetFont(stackFont, stackFontSize, "OUTLINE")
return f
end
local PoolIconResetterFunc = function(pool, f)
local db = NugPlateAuras.db.profile.buffGains
f:SetHeight(db.auraSize)
f:SetWidth(db.auraSize)
f.ag:Stop()
local angleRange = 30
local angle = math.random(0,angleRange)- (angleRange/2)
local distance = 70
local translateX = math.sin(math.rad(angle))*distance
local translateY = math.cos(math.rad(angle))*distance
f.ag.t1:SetOffset(translateX, translateY)
local np = pool.parent
f:SetPoint("BOTTOM", np, "TOP", 0, 0)
end
local PoolIconCreationFunc = function(pool)
local np = pool.parent
local f
-- if ns.MasqueGroup then
-- f = CreateFrame("Button", nil, np, "ActionButtonTemplate")
-- else
f = CreateFrame("Frame", nil, np)
-- end
f:EnableMouse(false)
f:SetFrameLevel(6)
-- f:SetHeight(25)
-- f:SetWidth(25)
-- if ns.MasqueGroup then
-- ns.MasqueGroup:AddButton(f)
-- else
local tex = f:CreateTexture(nil,"ARTWORK", nil, 0)
f.icon = tex
tex:SetTexCoord(0.07, 0.93, 0.07, 0.93)
tex:SetAllPoints(f)
-- end
f.icon:SetTexture("Interface\\Icons\\Spell_Shadow_SacrificialShield")
local ag = f:CreateAnimationGroup()
f.ag = ag
-- local scaleOrigin = "RIGHT"
local translateX = 0
local translateY = 100
-- f:SetAlpha(0)
-- local s1 = ag:CreateAnimation("Scale")
-- s1:SetScale(0.01,1)
-- s1:SetDuration(0)
-- s1:SetOrigin(scaleOrigin,0,0)
-- s1:SetOrder(1)
-- local s2 = ag:CreateAnimation("Scale")
-- s2:SetScale(100,1)
-- s2:SetDuration(0.5)
-- s2:SetOrigin(scaleOrigin,0,0)
-- s2:SetSmoothing("OUT")
-- s2:SetOrder(2)
local a1 = ag:CreateAnimation("Alpha")
a1:SetFromAlpha(0)
a1:SetToAlpha(1)
a1:SetDuration(0.3)
a1:SetOrder(2)
local t1 = ag:CreateAnimation("Translation")
t1:SetOffset(translateX,translateY)
t1:SetDuration(2)
t1:SetSmoothing("OUT")
t1:SetOrder(2)
local a2 = ag:CreateAnimation("Alpha")
a2:SetFromAlpha(1)
a2:SetToAlpha(0)
a2:SetSmoothing("OUT")
a2:SetDuration(0.5)
a2:SetStartDelay(1.5)
a2:SetOrder(2)
-- ag.s1 = s1
-- ag.s2 = s2
ag.t1 = t1
ag:SetScript("OnFinished", function(self)
local icon = self:GetParent()
icon:Hide()
pool:Release(icon)
end)
return f
end
local function FloatingIconHeader_Reconfigure(hdr, unit)
local headerType = hdr.headerType
local dbh = NugPlateAuras.db.profile[headerType]
hdr:SetPoint("BOTTOM", hdr:GetParent(), "TOP", dbh.npOffsetX, dbh.npOffsetY)
hdr:SetSize(dbh.auraSize, dbh.auraSize)
end
local CreateFramePool = nil
do
local ObjectPool = {
-- creationFunc = function(self)
-- return self.parent:CreateMaskTexture()
-- end,
-- resetterFunc = function(self, mask)
-- mask:Hide()
-- mask:ClearAllPoints()
-- end,
AddObject = function(self, object)
local dummy = true
self.activeObjects[object] = dummy
self.activeObjectCount = self.activeObjectCount + 1
end,
ReclaimObject = function(self, object)
tinsert(self.inactiveObjects, object)
self.activeObjects[object] = nil
self.activeObjectCount = self.activeObjectCount - 1
end,
Release = function(self, object)
local active = self.activeObjects[object] ~= nil
if active then
self:resetterFunc(object)
self:ReclaimObject(object)
end
return active
end,
Acquire = function(self)
local object = tremove(self.inactiveObjects)
local new = object == nil
if new then
object = self:creationFunc()
self:resetterFunc(object, new)
end
self:AddObject(object)
return object, new
end,
ReleaseAll = function(self)
for obj in pairs(self.activeObjects) do
self:Release(obj);
end
end,
Init = function(self, parent)
self.activeObjects = {}
self.inactiveObjects = {}
self.activeObjectCount = 0
self.parent = parent
end
}
local function Pool_HideAndClearAnchors(framePool, frame)
frame:Hide();
frame:ClearAllPoints();
end
local TextureDefaultReset = Pool_HideAndClearAnchors
local TextureDefaultCreate = function(texturePool)
return texturePool.parent:CreateTexture(nil, texturePool.layer, texturePool.textureTemplate, texturePool.subLayer);
end
-- local FrameDefaultResetter = Pool_HideAndClearAnchors
-- local function CreateTexturePool(parent, layer, subLayer, textureTemplate, resetterFunc)
-- local texturePool = setmetatable({}, { __index = ObjectPool })
-- texturePool:Init(parent)
-- texturePool.layer = layer;
-- texturePool.subLayer = subLayer;
-- texturePool.textureTemplate = textureTemplate;
-- texturePool.creationFunc = TextureDefaultCreate
-- texturePool.resetterFunc = TextureDefaultReset
-- return texturePool;
-- end
CreateFramePool = function(frameType, parent, frameTemplate, resetterFunc)
local framePool = setmetatable({}, { __index = ObjectPool })
framePool:Init(parent)
framePool.frameType = frameType;
framePool.frameTemplate = frameTemplate;
framePool.resetterFunc = resetterFunc or Pool_HideAndClearAnchors
return framePool
end
end
function NugPlateAuras:CreateFloatingIconPool(parent)
local hdr = CreateFrame("Frame", "$parentNPAHeaderBuffGains", parent)
hdr.headerType = "buffGains"
hdr.Reconfigure = FloatingIconHeader_Reconfigure
hdr:Reconfigure()
local template = nil
local resetterFunc = PoolIconResetterFunc
local iconPool = CreateFramePool("Frame", hdr, template, resetterFunc)
iconPool.creationFunc = PoolIconCreationFunc
hdr.pool = iconPool
return hdr
end
local MIRROR_POINTS = {
["TOPLEFT"] = "BOTTOMRIGHT",
["LEFT"] = "RIGHT",
["BOTTOMLEFT"] = "TOPRIGHT",
["TOPRIGHT"] = "BOTTOMLEFT",
["RIGHT"] = "LEFT",
["BOTTOMRIGHT"] = "TOPLEFT",
["CENTER"] = "CENTER",
["TOP"] = "BOTTOM",
["BOTTOM"] = "TOP",
};
local MIRROR_POINTS_HORIZONTAL = {
["TOPLEFT"] = "TOPRIGHT",
["LEFT"] = "RIGHT",
["BOTTOMLEFT"] = "BOTTOMRIGHT",
["TOPRIGHT"] = "TOPLEFT",
["RIGHT"] = "LEFT",
["BOTTOMRIGHT"] = "BOTTOMLEFT",
["CENTER"] = "CENTER",
["TOP"] = "TOP",
["BOTTOM"] = "BOTTOM",
};
local MIRROR_POINTS_VERTICAL = {
["TOPLEFT"] = "BOTTOMLEFT",
["LEFT"] = "LEFT",
["BOTTOMLEFT"] = "TOPLEFT",
["TOPRIGHT"] = "BOTTOMRIGHT",
["RIGHT"] = "RIGHT",
["BOTTOMRIGHT"] = "TOPRIGHT",
["CENTER"] = "CENTER",
["TOP"] = "BOTTOM",
["BOTTOM"] = "TOP",
};
function ns.ReverseOrientation(direction)
if direction == "HORIZONTAL" then
return "VERTICAL"
else
return "HORIZONTAL"
end
end
function ns.Reverse(p1, direction)
local mirrorTable = MIRROR_POINTS
if direction == "HORIZONTAL" then
mirrorTable = MIRROR_POINTS_HORIZONTAL
elseif direction == "VERTICAL" then
mirrorTable = MIRROR_POINTS_VERTICAL
end
local p2 = mirrorTable[p1]
if p2 == "RIGHT" or p2 == "LEFT" then
return p2, "HORIZONTAL"
elseif p2 == "TOP" or p2 == "BOTTOM" then
return p2, "VERTICAL"
end
return p2
end