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