Nenue@59
|
1 -- Veneer
|
Nenue@59
|
2 -- BuffFrame.lua
|
Nenue@59
|
3 -- Created: 7/27/2016 8:08 PM
|
Nenue@59
|
4 -- %file-revision%
|
Nenue@62
|
5 --[[
|
Nenue@62
|
6 Adds progress bars and cooldown swirls to buffbutton frames
|
Nenue@60
|
7
|
Nenue@62
|
8 Known Limitations:
|
Nenue@62
|
9 - Individual BuffButton frames are created upon use, making it difficult to do any sort of securestate priming
|
Nenue@62
|
10 - TempEnchant info returns relative values only, and they don't synchronize with aura events
|
Nenue@62
|
11 - BuffButtons can only be hidden/shown by blizzcode, so functions doing that have to be accounted for
|
Nenue@62
|
12 --]]
|
Nenue@62
|
13
|
Nenue@90
|
14
|
Nenue@75
|
15 local BUFFS_PER_ROW = 12
|
Nenue@64
|
16 local BUFF_BUTTON_SIZE = 48
|
Nenue@86
|
17 local BUFF_BUTTON_SPACING_H = 5
|
Nenue@71
|
18 local BUFF_BUTTON_SPACING_V = 14
|
Nenue@64
|
19 local BUFF_PROGRESS_SIZE = 4
|
Nenue@86
|
20 local BUFF_PROGRESS_INSET = 2
|
Nenue@86
|
21 local PROGRESS_ANCHOR = 'BOTTOM'
|
Nenue@86
|
22 local PROGRESS_PARENT
|
Nenue@86
|
23 local PROGRESS_OFFSET = 1
|
Nenue@86
|
24
|
Nenue@68
|
25 local BUFF_BUTTON_ZOOM = .15
|
Nenue@86
|
26 local BORDER_SIZE_L = 2
|
Nenue@86
|
27 local BORDER_SIZE_R = 2
|
Nenue@86
|
28 local BORDER_SIZE_U = 2
|
Nenue@86
|
29 local BORDER_SIZE_D = 2
|
Nenue@75
|
30 local BUFF_FRAMES_X = -230
|
Nenue@75
|
31 local BUFF_FRAMES_Y = -4
|
Nenue@64
|
32
|
Nenue@86
|
33 local COUNT_ANCHOR = 'TOPRIGHT'
|
Nenue@86
|
34 local COUNT_INSET = 4
|
Nenue@86
|
35 local COUNT_PARENT
|
Nenue@86
|
36
|
Nenue@86
|
37 local DURATION_ANCHOR = 'BOTTOMLEFT'
|
Nenue@86
|
38 local DURATION_INSET = 4
|
Nenue@86
|
39 local DURATION_PARENT
|
Nenue@86
|
40
|
Nenue@84
|
41 VeneerBuffFrameMixin = {
|
Nenue@84
|
42 moduleName = 'Buff Frames',
|
Nenue@84
|
43 defaultCluster = 'TOPRIGHT',
|
Nenue@90
|
44 anchorX = BUFF_FRAMES_X,
|
Nenue@90
|
45 anchorY = BUFF_FRAMES_Y,
|
Nenue@90
|
46 anchorPoint = 'TOPRIGHT',
|
Nenue@84
|
47 Buttons = {},
|
Nenue@84
|
48 DetectedFrames = {},
|
Nenue@84
|
49 AuraCache = {}
|
Nenue@84
|
50 }
|
Nenue@90
|
51 VeneerBuffFrameButtonMixin = {
|
Nenue@90
|
52 }
|
Nenue@84
|
53 local plugin = VeneerBuffFrameMixin
|
Nenue@62
|
54
|
Nenue@84
|
55 local vn = Veneer
|
Nenue@84
|
56 local print = DEVIAN_WORKSPACE and function(...) _G.print('BuffFrame', ...) end or function() end
|
Nenue@68
|
57 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end
|
Nenue@59
|
58
|
Nenue@68
|
59 local _G, UIParent = _G, UIParent
|
Nenue@68
|
60 local tinsert, tremove, unpack, select, tconcat = table.insert, table.remove, unpack, select, table.concat
|
Nenue@68
|
61 local floor, tonumber, format = math.floor, tonumber, string.format
|
Nenue@68
|
62 local UnitAura, GetTime, CreateFrame = UnitAura, GetTime, CreateFrame
|
Nenue@68
|
63 local hooksecurefunc = hooksecurefunc
|
Nenue@59
|
64
|
Nenue@75
|
65 local aurasCache = {}
|
Nenue@75
|
66 local skinnedFrames = {}
|
Nenue@75
|
67 local pendingFrames = {}
|
Nenue@75
|
68 local veneers = {}
|
Nenue@75
|
69 local expirationCache = {}
|
Nenue@75
|
70 local visibility = {}
|
Nenue@75
|
71 local isHooked = {}
|
Nenue@75
|
72
|
Nenue@75
|
73 plugin.options = {
|
Nenue@75
|
74 nameString = 'Buff Frames',
|
Nenue@59
|
75 {
|
Nenue@75
|
76 name = 'BuffButtonZoom',
|
Nenue@75
|
77 type = 'slider',
|
Nenue@75
|
78 min = 0,
|
Nenue@75
|
79 max = 100,
|
Nenue@75
|
80 fullwidth = true,
|
Nenue@59
|
81 },
|
Nenue@59
|
82 {
|
Nenue@75
|
83 name = 'BuffBorderLeft',
|
Nenue@75
|
84 type = 'slider',
|
Nenue@75
|
85 min = 0,
|
Nenue@75
|
86 max = 16,
|
Nenue@59
|
87 },
|
Nenue@59
|
88 {
|
Nenue@75
|
89 name = 'BuffBorderLeft',
|
Nenue@75
|
90 type = 'slider',
|
Nenue@75
|
91 min = 0,
|
Nenue@75
|
92 max = 16,
|
Nenue@59
|
93 }
|
Nenue@59
|
94 }
|
Nenue@59
|
95
|
Nenue@86
|
96 local OFFSET_PARALLELS = {
|
Nenue@86
|
97 TOP = {'LEFT', 'RIGHT', 'SetHeight'},
|
Nenue@86
|
98 BOTTOM = {'LEFT', 'RIGHT', 'SetHeight'},
|
Nenue@86
|
99 LEFT = {'TOP', 'BOTTOM', 'SetWidth'},
|
Nenue@86
|
100 RIGHT = {'TOP', 'BOTTOM', 'SetWidth'},
|
Nenue@86
|
101 }
|
Nenue@86
|
102 local ANCHOR_OFFSET_POINT = {
|
Nenue@86
|
103 TOP = 'BOTTOM',
|
Nenue@86
|
104 TOPLEFT = 'BOTTOMRIGHT',
|
Nenue@86
|
105 TOPRIGHT = 'BOTTOMLEFT',
|
Nenue@86
|
106 LEFT = 'RIGHT',
|
Nenue@86
|
107 RIGHT = 'LEFT',
|
Nenue@86
|
108 CENTER = 'CENTER',
|
Nenue@86
|
109 BOTTOM = 'TOP',
|
Nenue@86
|
110 BOTTOMRIGHT = 'TOPLEFT',
|
Nenue@86
|
111 BOTTOMLEFT = 'TOPRIGHT',
|
Nenue@86
|
112 }
|
Nenue@86
|
113 local ANCHOR_INSET_DELTA = {
|
Nenue@86
|
114 TOP = {0, -1},
|
Nenue@86
|
115 TOPLEFT = {1, -1},
|
Nenue@86
|
116 TOPRIGHT = {-1,-1},
|
Nenue@86
|
117 LEFT = {1, 0},
|
Nenue@86
|
118 BOTTOMLEFT = {1, 1},
|
Nenue@86
|
119 BOTTOM = {0, 1},
|
Nenue@86
|
120 BOTTOMRIGHT = {-1, 1},
|
Nenue@86
|
121 RIGHT = {-1, 0},
|
Nenue@86
|
122 CENTER = {0, 0},
|
Nenue@86
|
123 }
|
Nenue@59
|
124
|
Nenue@90
|
125 -- Associates skinning elements with said button
|
Nenue@90
|
126 local surrogates = {
|
Nenue@90
|
127 ['Show'] = false,
|
Nenue@90
|
128 ['Hide'] = false,
|
Nenue@90
|
129 ['SetText'] = false,
|
Nenue@90
|
130 ['SetVertexColor'] = function(self, region, r, g, b, a)
|
Nenue@90
|
131 if not self.progress then
|
Nenue@90
|
132 return
|
Nenue@90
|
133 end
|
Nenue@90
|
134
|
Nenue@90
|
135 region:Hide()
|
Nenue@90
|
136 tprint('|cFF0088FFborder:SetVertexColor|r', r,g,b,a)
|
Nenue@90
|
137 self.progress.fg:SetColorTexture(r,g,b,a)
|
Nenue@90
|
138 self.border:SetColorTexture(r,g,b,a)
|
Nenue@90
|
139 self.border:Show()
|
Nenue@90
|
140 end,
|
Nenue@90
|
141 }
|
Nenue@90
|
142 local DoRegionHooks = function (veneer, region)
|
Nenue@90
|
143
|
Nenue@90
|
144 if region then
|
Nenue@90
|
145 --print('hooking', region:GetName())
|
Nenue@90
|
146 region:ClearAllPoints()
|
Nenue@90
|
147 for method, callback in pairs(surrogates) do
|
Nenue@90
|
148 if type(region[method]) == 'function' then
|
Nenue@90
|
149
|
Nenue@90
|
150 --print(method, type(callback))
|
Nenue@90
|
151 local func
|
Nenue@90
|
152 if callback then
|
Nenue@90
|
153 hooksecurefunc(region, method, function(self, ...)
|
Nenue@90
|
154 --tprint('|cFF00FFFF'.. region:GetName().. ':', method)
|
Nenue@90
|
155 region:ClearAllPoints()
|
Nenue@90
|
156 callback(veneer, region, ...)
|
Nenue@90
|
157 end)
|
Nenue@90
|
158 else
|
Nenue@90
|
159 hooksecurefunc(region, method, function(self,...)
|
Nenue@90
|
160 tprint('|cFF0088FF'.. self:GetName().. ':', method)
|
Nenue@90
|
161 self:ClearAllPoints()
|
Nenue@90
|
162 veneer:Show()
|
Nenue@90
|
163 veneer[method](veneer, ...)
|
Nenue@90
|
164
|
Nenue@90
|
165 if self:GetName():match('Debuff.+Count') then
|
Nenue@90
|
166
|
Nenue@90
|
167 print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')')
|
Nenue@90
|
168 print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText())
|
Nenue@90
|
169 print(veneer:GetTop(), veneer:GetLeft())
|
Nenue@90
|
170 print(veneer:GetPoint(1))
|
Nenue@90
|
171 end
|
Nenue@90
|
172
|
Nenue@90
|
173 end)
|
Nenue@90
|
174 end
|
Nenue@90
|
175 end
|
Nenue@90
|
176 end
|
Nenue@90
|
177 end
|
Nenue@90
|
178 end
|
Nenue@90
|
179 function VeneerBuffFrameMixin:Acquire(target)
|
Nenue@75
|
180
|
Nenue@84
|
181 local frame = self.Buttons[target]
|
Nenue@84
|
182 if not (self.Buttons[target]) then
|
Nenue@84
|
183 local name = target:GetName()
|
Nenue@84
|
184 local id = target:GetID()
|
Nenue@68
|
185 print('|cFF88FF00Creating', name,'Veneer')
|
Nenue@59
|
186
|
Nenue@84
|
187 frame = vn:Acquire(target, 'VeneerBuffTemplate')
|
Nenue@59
|
188
|
Nenue@86
|
189 frame.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](frame.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@86
|
190 print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@86
|
191
|
Nenue@86
|
192 frame.progress:ClearAllPoints()
|
Nenue@86
|
193 frame.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or frame.border, PROGRESS_ANCHOR,
|
Nenue@86
|
194 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1),
|
Nenue@86
|
195 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1))
|
Nenue@86
|
196 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0)
|
Nenue@86
|
197 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0)
|
Nenue@86
|
198
|
Nenue@86
|
199 print(frame.progress:GetPoint(1))
|
Nenue@86
|
200 print(frame.progress:GetPoint(2))
|
Nenue@86
|
201 print(frame.progress:GetPoint(3))
|
Nenue@86
|
202 frame.progress:Show()
|
Nenue@86
|
203
|
Nenue@86
|
204 frame.progress.bg:ClearAllPoints()
|
Nenue@86
|
205 frame.progress.bg:SetAllPoints(frame.progress)
|
Nenue@59
|
206
|
Nenue@84
|
207 frame.progress.fg:ClearAllPoints()
|
Nenue@84
|
208 frame.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
|
Nenue@84
|
209 frame.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
|
Nenue@86
|
210 --frame.count:ClearAllPoints()
|
Nenue@86
|
211 --frame.count:SetPoint('TOPRIGHT', frame,'TOPRIGHT', -3, -3)
|
Nenue@75
|
212
|
Nenue@59
|
213
|
Nenue@86
|
214 frame.duration:ClearAllPoints()
|
Nenue@86
|
215 frame.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or frame, DURATION_ANCHOR,
|
Nenue@86
|
216 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET),
|
Nenue@86
|
217 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET))
|
Nenue@86
|
218
|
Nenue@86
|
219 frame.count:ClearAllPoints()
|
Nenue@86
|
220 frame.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or frame, COUNT_ANCHOR,
|
Nenue@86
|
221 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET),
|
Nenue@86
|
222 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET))
|
Nenue@86
|
223
|
Nenue@84
|
224 frame.underlay:SetParent(UIParent)
|
Nenue@84
|
225 frame.underlay:SetFrameStrata('BACKGROUND')
|
Nenue@84
|
226 frame.border:SetColorTexture(0,0,0,1)
|
Nenue@84
|
227 frame.border:SetPoint('TOPLEFT', frame, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U)
|
Nenue@84
|
228 frame.border:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D)
|
Nenue@84
|
229 frame.border:Show()
|
Nenue@59
|
230
|
Nenue@84
|
231 self.Buttons[target] = frame
|
Nenue@59
|
232 end
|
Nenue@84
|
233 return frame
|
Nenue@59
|
234 end
|
Nenue@59
|
235
|
Nenue@90
|
236 function VeneerBuffFrameMixin:OnLoad()
|
Nenue@84
|
237 Veneer:AddHandler(self, self.defaultCluster)
|
Nenue@84
|
238 end
|
Nenue@68
|
239
|
Nenue@90
|
240 function VeneerBuffFrameMixin:Setup()
|
Nenue@84
|
241
|
Nenue@84
|
242
|
Nenue@84
|
243 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end)
|
Nenue@84
|
244 hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end)
|
Nenue@84
|
245 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end)
|
Nenue@84
|
246 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function(...) self:OnUpdateAllBuffAnchors(...) end)
|
Nenue@84
|
247 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end)
|
Nenue@84
|
248 for i = 1, 3 do
|
Nenue@84
|
249 self:SetupButton('TempEnchant'..i)
|
Nenue@84
|
250 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1)
|
Nenue@84
|
251 end
|
Nenue@84
|
252 end
|
Nenue@86
|
253
|
Nenue@84
|
254
|
Nenue@90
|
255 function VeneerBuffFrameMixin:SetupButton (name)
|
Nenue@68
|
256 local frame = _G[name ]
|
Nenue@84
|
257 if self.DetectedFrames[frame] then
|
Nenue@86
|
258 --print('|cFFFF4400Attempting to skin a frame that already went through.|r')
|
Nenue@68
|
259 return
|
Nenue@68
|
260 end
|
Nenue@86
|
261 --print('|cFFFFFF00Adopting', name)
|
Nenue@68
|
262
|
Nenue@68
|
263 local icon = _G[name .. 'Icon']
|
Nenue@68
|
264 local border = _G[name .. 'Border']
|
Nenue@68
|
265 local count = _G[name .. 'Count']
|
Nenue@68
|
266 local duration = _G[name .. 'Duration']
|
Nenue@84
|
267 local veneer = self:Acquire(frame)
|
Nenue@84
|
268 local offset = BUFF_BUTTON_ZOOM/2
|
Nenue@68
|
269
|
Nenue@84
|
270 self.DetectedFrames[frame] = frame
|
Nenue@68
|
271 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
|
Nenue@84
|
272 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset)
|
Nenue@68
|
273
|
Nenue@78
|
274
|
Nenue@86
|
275
|
Nenue@84
|
276 DoRegionHooks(veneer, border)
|
Nenue@68
|
277 if border then
|
Nenue@68
|
278 local color = DebuffTypeColor["none"]
|
Nenue@68
|
279 if aurasCache[frame] and aurasCache[frame][5] then
|
Nenue@68
|
280 color = DebuffTypeColor[aurasCache[frame][5]]
|
Nenue@68
|
281 end
|
Nenue@71
|
282 veneer.progress.fg:SetColorTexture(color.r,color.g,color.b)
|
Nenue@75
|
283 veneer.border:SetColorTexture(0,0,0,1)
|
Nenue@79
|
284 veneer.border:Show()
|
Nenue@79
|
285 else
|
Nenue@79
|
286 veneer.border:SetColorTexture(0,0,0,1)
|
Nenue@79
|
287 veneer.border:Show()
|
Nenue@68
|
288 end
|
Nenue@68
|
289
|
Nenue@86
|
290 if count and count:GetText() then
|
Nenue@86
|
291 count:ClearAllPoints()
|
Nenue@86
|
292 veneer.count:SetText(count:GetText())
|
Nenue@86
|
293 end
|
Nenue@86
|
294 if duration then
|
Nenue@86
|
295 duration:ClearAllPoints()
|
Nenue@86
|
296 end
|
Nenue@86
|
297
|
Nenue@86
|
298
|
Nenue@86
|
299
|
Nenue@68
|
300
|
Nenue@68
|
301 hooksecurefunc(frame, "Hide", function(self)
|
Nenue@68
|
302 local isVisible = self:IsVisible()
|
Nenue@68
|
303 if isVisible ~= visibility[self] then
|
Nenue@68
|
304 visibility[self] = isVisible
|
Nenue@68
|
305 end
|
Nenue@68
|
306 veneer:Hide()
|
Nenue@73
|
307 veneer.underlay:Hide()
|
Nenue@68
|
308 end)
|
Nenue@68
|
309
|
Nenue@68
|
310 hooksecurefunc(frame, 'Show', function(self)
|
Nenue@68
|
311 veneer:Show()
|
Nenue@68
|
312 local isVisible = self:IsVisible()
|
Nenue@68
|
313 if isVisible ~= visibility[self] then
|
Nenue@68
|
314 print('|cFFFFFF00SHOW|r', self:GetName())
|
Nenue@68
|
315 visibility[self] = isVisible
|
Nenue@68
|
316 end
|
Nenue@74
|
317 veneer.underlay:Show()
|
Nenue@68
|
318 end)
|
Nenue@68
|
319
|
Nenue@68
|
320 end
|
Nenue@68
|
321
|
Nenue@68
|
322
|
Nenue@61
|
323 --- Set widgets to reflect the passed parameters
|
Nenue@90
|
324 function VeneerBuffFrameMixin:UpdateButton (frame, duration, expires)
|
Nenue@84
|
325 local veneer = self:Acquire(frame)
|
Nenue@68
|
326 -- is it a new button?
|
Nenue@84
|
327 if not self.DetectedFrames[frame] then
|
Nenue@84
|
328 self:SetupButton(frame:GetName())
|
Nenue@68
|
329 end
|
Nenue@68
|
330
|
Nenue@86
|
331 --[[
|
Nenue@86
|
332 if frame.count then
|
Nenue@86
|
333 frame.count:SetText('test')
|
Nenue@86
|
334 frame.count:Show()
|
Nenue@86
|
335 end
|
Nenue@86
|
336 --]]
|
Nenue@86
|
337 local name, rank, icon, count, _, duration, expires = UnitAura(frame.unit, frame:GetID(), frame.filter)
|
Nenue@86
|
338
|
Nenue@59
|
339
|
Nenue@61
|
340 if expires and duration then
|
Nenue@61
|
341 if duration ~= 0 then
|
Nenue@61
|
342 local startTime = (expires - duration)
|
Nenue@61
|
343 local endTime = expires or 0
|
Nenue@61
|
344 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires)
|
Nenue@61
|
345 veneer.progress:Show()
|
Nenue@61
|
346 veneer.elapsed = 0
|
Nenue@61
|
347 veneer.progress:SetScript('OnUpdate', function(self, elapsed)
|
Nenue@61
|
348 veneer.elapsed = veneer.elapsed + elapsed
|
Nenue@60
|
349
|
Nenue@67
|
350 local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2)
|
Nenue@61
|
351 local t = GetTime()
|
Nenue@61
|
352 local progress = (t - startTime) / duration
|
Nenue@61
|
353
|
Nenue@67
|
354 local nw = (w - (w * progress))
|
Nenue@61
|
355 if veneer.elapsed >= 0.25 then
|
Nenue@61
|
356
|
Nenue@68
|
357 tprint(t, startTime, floor(progress*100), w * progress, nw, w)
|
Nenue@61
|
358 veneer.elapsed = 0.25 - veneer.elapsed
|
Nenue@61
|
359 end
|
Nenue@61
|
360 if (progress >= 1) or not frame:IsVisible() then
|
Nenue@61
|
361 veneer.startTime = nil
|
Nenue@61
|
362 self:Hide()
|
Nenue@61
|
363 self:SetScript('OnUpdate', nil)
|
Nenue@61
|
364 else
|
Nenue@61
|
365 self.fg:SetWidth(nw)
|
Nenue@61
|
366 end
|
Nenue@61
|
367 end)
|
Nenue@61
|
368
|
Nenue@61
|
369 veneer.cooldown:Show()
|
Nenue@61
|
370 veneer.cooldown:SetCooldown(startTime, duration)
|
Nenue@61
|
371 else
|
Nenue@61
|
372 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero')
|
Nenue@61
|
373 veneer.progress:SetScript('OnUpdate', nil)
|
Nenue@61
|
374 veneer.progress:Hide()
|
Nenue@61
|
375 veneer.cooldown:Hide()
|
Nenue@61
|
376 end
|
Nenue@86
|
377
|
Nenue@90
|
378 if count and count > 1 then
|
Nenue@86
|
379 veneer.count:SetText(count)
|
Nenue@86
|
380 veneer.count:Show()
|
Nenue@90
|
381 frame.count:ClearAllPoints()
|
Nenue@86
|
382 else
|
Nenue@86
|
383 veneer.count:Hide()
|
Nenue@86
|
384 end
|
Nenue@86
|
385
|
Nenue@86
|
386
|
Nenue@61
|
387 else
|
Nenue@61
|
388 veneer.progress:Hide()
|
Nenue@61
|
389 veneer.cooldown:SetCooldown(0,0)
|
Nenue@61
|
390 veneer.cooldown:Hide()
|
Nenue@61
|
391 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration')
|
Nenue@59
|
392 end
|
Nenue@59
|
393 veneer:Show()
|
Nenue@59
|
394 end
|
Nenue@59
|
395
|
Nenue@59
|
396
|
Nenue@59
|
397 --- Provides the number of changed indices for use in deciding between partial and full veneer updates
|
Nenue@90
|
398 function VeneerBuffFrameMixin:ButtonHasChanged (frame, ...)
|
Nenue@59
|
399 aurasCache[frame] = aurasCache[frame] or {}
|
Nenue@59
|
400 local hasChange = 0
|
Nenue@59
|
401 local numVals = select('#',...)
|
Nenue@59
|
402 for i = 1, numVals do
|
Nenue@59
|
403 local arg = select(i, ...)
|
Nenue@59
|
404 if aurasCache[frame][i] ~= arg then
|
Nenue@59
|
405 hasChange = hasChange + 1
|
Nenue@59
|
406 end
|
Nenue@59
|
407 aurasCache[frame][i] = arg
|
Nenue@59
|
408 end
|
Nenue@59
|
409 return hasChange
|
Nenue@59
|
410 end
|
Nenue@59
|
411
|
Nenue@90
|
412 function VeneerBuffFrameMixin:OnAuraButton_Update (name, index, filter)
|
Nenue@59
|
413 local bName = name..index
|
Nenue@59
|
414 local frame = _G[bName]
|
Nenue@59
|
415 if frame and frame:IsVisible() then
|
Nenue@61
|
416 -- if the name or expirationTime changed
|
Nenue@86
|
417
|
Nenue@61
|
418 if not skinnedFrames[frame] then
|
Nenue@61
|
419 tinsert(pendingFrames, frame)
|
Nenue@61
|
420 end
|
Nenue@59
|
421 expirationCache[name] = frame.expirationTime
|
Nenue@86
|
422 self:UpdateButton(frame)
|
Nenue@68
|
423
|
Nenue@59
|
424
|
Nenue@59
|
425 end
|
Nenue@59
|
426 end
|
Nenue@59
|
427
|
Nenue@90
|
428 function VeneerBuffFrameMixin:OnUpdateAllBuffAnchors ()
|
Nenue@59
|
429 local todo = {}
|
Nenue@59
|
430 if #pendingFrames >= 1 then
|
Nenue@59
|
431
|
Nenue@59
|
432 print('|cFFBBFF00AllBuffAnchors|r', #pendingFrames)
|
Nenue@59
|
433 while pendingFrames[1] do
|
Nenue@59
|
434 local frame = tremove(pendingFrames)
|
Nenue@59
|
435 tinsert(todo, frame:GetName())
|
Nenue@59
|
436
|
Nenue@61
|
437 -- re-apply custom anchors
|
Nenue@59
|
438 end
|
Nenue@68
|
439 print(tconcat(todo, ', '))
|
Nenue@59
|
440 end
|
Nenue@59
|
441 --BuffButton1
|
Nenue@59
|
442 --DebuffButton1
|
Nenue@61
|
443 --todo: separate frame groups and iterate over them at appropriate times
|
Nenue@60
|
444 if BuffButton1 then
|
Nenue@78
|
445
|
Nenue@68
|
446 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0)
|
Nenue@60
|
447 end
|
Nenue@60
|
448
|
Nenue@70
|
449 local lastBuff, topBuff
|
Nenue@74
|
450 local numBuffs = 0
|
Nenue@90
|
451 local numColumns = 1
|
Nenue@90
|
452 local maxColumn = 1
|
Nenue@70
|
453 for i = 1, BUFF_ACTUAL_DISPLAY do
|
Nenue@70
|
454 local buff = _G['BuffButton'..i]
|
Nenue@70
|
455 if buff then
|
Nenue@74
|
456 numBuffs = numBuffs + 1
|
Nenue@74
|
457 buff:ClearAllPoints()
|
Nenue@75
|
458 if mod(numBuffs,BUFFS_PER_ROW) == 1 then
|
Nenue@74
|
459 if numBuffs == 1 then
|
Nenue@80
|
460 buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
|
Nenue@90
|
461 plugin.currentTop = buff
|
Nenue@71
|
462 else
|
Nenue@71
|
463 buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@71
|
464 end
|
Nenue@90
|
465 numColumns = 1
|
Nenue@70
|
466 topBuff = buff
|
Nenue@70
|
467 else
|
Nenue@71
|
468 buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@90
|
469 numColumns = numColumns + 1
|
Nenue@90
|
470 end
|
Nenue@90
|
471 if numColumns > maxColumn then
|
Nenue@90
|
472 maxColumn = numColumns
|
Nenue@90
|
473 plugin.currentLeft = buff
|
Nenue@70
|
474 end
|
Nenue@70
|
475 lastBuff = buff
|
Nenue@70
|
476 end
|
Nenue@70
|
477 end
|
Nenue@70
|
478
|
Nenue@74
|
479 numBuffs = 0
|
Nenue@70
|
480 for i = 1, DEBUFF_ACTUAL_DISPLAY do
|
Nenue@70
|
481 local debuff = _G['DebuffButton'..i]
|
Nenue@70
|
482 if debuff then
|
Nenue@74
|
483 numBuffs = numBuffs + 1
|
Nenue@74
|
484 if numBuffs == 1 then
|
Nenue@70
|
485 if topBuff then
|
Nenue@71
|
486 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@70
|
487 else
|
Nenue@70
|
488 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
|
Nenue@70
|
489 end
|
Nenue@70
|
490 topBuff = debuff
|
Nenue@75
|
491 elseif mod(numBuffs, BUFFS_PER_ROW) == 1 then
|
Nenue@71
|
492 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@70
|
493 topBuff = debuff
|
Nenue@70
|
494 else
|
Nenue@71
|
495 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@70
|
496 end
|
Nenue@70
|
497 lastBuff = debuff
|
Nenue@70
|
498 end
|
Nenue@70
|
499 end
|
Nenue@70
|
500
|
Nenue@74
|
501 if lastBuff then
|
Nenue@90
|
502 plugin.currentBottom = lastBuff
|
Nenue@74
|
503 end
|
Nenue@90
|
504
|
Nenue@90
|
505 self.Background:ClearAllPoints()
|
Nenue@90
|
506 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4)
|
Nenue@90
|
507 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4)
|
Nenue@90
|
508 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0)
|
Nenue@59
|
509 end
|
Nenue@90
|
510 function VeneerBuffFrameMixin:UpdateConfigLayers (configMode)
|
Nenue@90
|
511 self:SetShown(configMode)
|
Nenue@90
|
512 end
|
Nenue@90
|
513 function VeneerBuffFrameMixin:OnUpdateDuration (frame, timeLeft)
|
Nenue@84
|
514 local veneer = self:Acquire(frame)
|
Nenue@60
|
515 local hours = floor(timeLeft/3600)
|
Nenue@60
|
516 local minutes = floor(mod(timeLeft, 3600)/60)
|
Nenue@60
|
517 local seconds = floor(mod(timeLeft, 60))
|
Nenue@60
|
518 local timeString = '%ds'
|
Nenue@59
|
519 if timeLeft > 3600 then
|
Nenue@60
|
520 timeString = format('%d:%02d', hours, minutes)
|
Nenue@60
|
521 elseif timeLeft > 60 then
|
Nenue@60
|
522 timeString = format('%d:%02d', minutes, seconds)
|
Nenue@61
|
523 else
|
Nenue@60
|
524 timeString = format('%d', seconds)
|
Nenue@59
|
525 end
|
Nenue@59
|
526
|
Nenue@74
|
527 if timeLeft < 10 then
|
Nenue@74
|
528 if not veneer.duration.getHuge then
|
Nenue@74
|
529 veneer.duration.getHuge = true
|
Nenue@74
|
530 veneer.duration:SetFontObject(VeneerNumberFontLarge)
|
Nenue@75
|
531 veneer.duration:SetTextColor(1,1,0,1)
|
Nenue@74
|
532 end
|
Nenue@74
|
533 else
|
Nenue@74
|
534 if veneer.duration.getHuge then
|
Nenue@74
|
535 veneer.duration.getHuge = nil
|
Nenue@74
|
536 veneer.duration:SetFontObject(VeneerNumberFont)
|
Nenue@74
|
537 veneer.duration:SetTextColor(1,1,1,1)
|
Nenue@74
|
538 end
|
Nenue@74
|
539 end
|
Nenue@74
|
540
|
Nenue@69
|
541 veneer.duration:SetText(timeString)
|
Nenue@59
|
542 end
|
Nenue@59
|
543
|
Nenue@59
|
544
|
Nenue@59
|
545 -- Obtains the first instance of Tenchant use
|
Nenue@59
|
546
|
Nenue@90
|
547 function VeneerBuffFrameMixin:OnTemporaryEnchantFrameUpdate (...)
|
Nenue@59
|
548 local numVals = select('#', ...)
|
Nenue@59
|
549 local numItems = numVals / 4
|
Nenue@59
|
550 if numItems >= 1 then
|
Nenue@59
|
551 for itemIndex = numItems, 1, -1 do
|
Nenue@59
|
552 local frame = _G['TempEnchant'..itemIndex]
|
Nenue@59
|
553 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...)
|
Nenue@59
|
554
|
Nenue@59
|
555
|
Nenue@59
|
556 if hasEnchant then
|
Nenue@59
|
557 local endTime = floor(GetTime()*1000) + timeRemaining
|
Nenue@59
|
558
|
Nenue@59
|
559
|
Nenue@59
|
560 --print(endTime)
|
Nenue@59
|
561 if endTime ~= expirationCache[frame] then
|
Nenue@59
|
562 if expirationCache[frame] then
|
Nenue@59
|
563 print(endTime, expirationCache[frame], endTime - expirationCache[frame])
|
Nenue@59
|
564 end
|
Nenue@59
|
565 expirationCache[frame] = endTime
|
Nenue@59
|
566 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000))
|
Nenue@59
|
567 UpdateVeneer(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000))
|
Nenue@59
|
568 end
|
Nenue@59
|
569 else
|
Nenue@84
|
570 self:Acquire(frame):Hide()
|
Nenue@59
|
571 end
|
Nenue@59
|
572
|
Nenue@59
|
573 end
|
Nenue@59
|
574
|
Nenue@59
|
575 end
|
Nenue@59
|
576
|
Nenue@59
|
577 end
|
Nenue@90
|
578 function VeneerBuffFrameMixin:OnBuffFrameUpdate ()
|
Nenue@59
|
579 end
|
Nenue@59
|
580
|
Nenue@59
|
581
|
Nenue@90
|
582 function VeneerBuffFrameButtonMixin:OnLoad()
|
Nenue@90
|
583
|
Nenue@90
|
584 self.duration = self.progress.duration
|
Nenue@90
|
585 self.count = self.overlay.count
|
Nenue@90
|
586 self.border = self.underlay.bg
|
Nenue@90
|
587
|
Nenue@90
|
588 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {}
|
Nenue@90
|
589 self.configIndex = #VeneerBuffFrame.ConfigLayers
|
Nenue@90
|
590 for i, region in ipairs(self.ConfigLayers) do
|
Nenue@90
|
591 tinsert(VeneerBuffFrame.ConfigLayers, region)
|
Nenue@90
|
592 end
|
Nenue@90
|
593
|
Nenue@90
|
594 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers
|
Nenue@90
|
595 end
|
Nenue@90
|
596
|
Nenue@84
|
597 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
|
Nenue@59
|
598
|