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@93
|
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@93
|
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@93
|
167 --print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')')
|
Nenue@93
|
168 --print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText())
|
Nenue@93
|
169 --print(veneer:GetTop(), veneer:GetLeft())
|
Nenue@93
|
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@93
|
183
|
Nenue@84
|
184 local name = target:GetName()
|
Nenue@84
|
185 local id = target:GetID()
|
Nenue@68
|
186 print('|cFF88FF00Creating', name,'Veneer')
|
Nenue@93
|
187 frame = vn:Acquire(target, 'VeneerBuffTemplate')
|
Nenue@59
|
188
|
Nenue@59
|
189
|
Nenue@86
|
190 frame.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](frame.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@86
|
191 print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@86
|
192
|
Nenue@86
|
193 frame.progress:ClearAllPoints()
|
Nenue@86
|
194 frame.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or frame.border, PROGRESS_ANCHOR,
|
Nenue@86
|
195 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1),
|
Nenue@86
|
196 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1))
|
Nenue@86
|
197 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0)
|
Nenue@86
|
198 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0)
|
Nenue@86
|
199
|
Nenue@86
|
200 print(frame.progress:GetPoint(1))
|
Nenue@86
|
201 print(frame.progress:GetPoint(2))
|
Nenue@86
|
202 print(frame.progress:GetPoint(3))
|
Nenue@86
|
203 frame.progress:Show()
|
Nenue@86
|
204
|
Nenue@86
|
205 frame.progress.bg:ClearAllPoints()
|
Nenue@86
|
206 frame.progress.bg:SetAllPoints(frame.progress)
|
Nenue@59
|
207
|
Nenue@84
|
208 frame.progress.fg:ClearAllPoints()
|
Nenue@84
|
209 frame.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
|
Nenue@84
|
210 frame.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
|
Nenue@86
|
211 --frame.count:ClearAllPoints()
|
Nenue@86
|
212 --frame.count:SetPoint('TOPRIGHT', frame,'TOPRIGHT', -3, -3)
|
Nenue@75
|
213
|
Nenue@59
|
214
|
Nenue@86
|
215 frame.duration:ClearAllPoints()
|
Nenue@86
|
216 frame.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or frame, DURATION_ANCHOR,
|
Nenue@86
|
217 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET),
|
Nenue@86
|
218 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET))
|
Nenue@86
|
219
|
Nenue@86
|
220 frame.count:ClearAllPoints()
|
Nenue@86
|
221 frame.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or frame, COUNT_ANCHOR,
|
Nenue@86
|
222 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET),
|
Nenue@86
|
223 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET))
|
Nenue@86
|
224
|
Nenue@84
|
225 frame.underlay:SetParent(UIParent)
|
Nenue@84
|
226 frame.underlay:SetFrameStrata('BACKGROUND')
|
Nenue@84
|
227 frame.border:SetColorTexture(0,0,0,1)
|
Nenue@84
|
228 frame.border:SetPoint('TOPLEFT', frame, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U)
|
Nenue@84
|
229 frame.border:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D)
|
Nenue@84
|
230 frame.border:Show()
|
Nenue@59
|
231
|
Nenue@84
|
232 self.Buttons[target] = frame
|
Nenue@59
|
233 end
|
Nenue@84
|
234 return frame
|
Nenue@59
|
235 end
|
Nenue@59
|
236
|
Nenue@90
|
237 function VeneerBuffFrameMixin:OnLoad()
|
Nenue@84
|
238 Veneer:AddHandler(self, self.defaultCluster)
|
Nenue@84
|
239 end
|
Nenue@68
|
240
|
Nenue@90
|
241 function VeneerBuffFrameMixin:Setup()
|
Nenue@84
|
242
|
Nenue@84
|
243
|
Nenue@84
|
244 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end)
|
Nenue@93
|
245 --hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end)
|
Nenue@84
|
246 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end)
|
Nenue@84
|
247 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function(...) self:OnUpdateAllBuffAnchors(...) end)
|
Nenue@84
|
248 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end)
|
Nenue@84
|
249 for i = 1, 3 do
|
Nenue@84
|
250 self:SetupButton('TempEnchant'..i)
|
Nenue@84
|
251 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1)
|
Nenue@84
|
252 end
|
Nenue@84
|
253 end
|
Nenue@86
|
254
|
Nenue@93
|
255 function VeneerBuffFrameMixin:SetHidden(region)
|
Nenue@93
|
256 if not self.hiddenRegions[region] then
|
Nenue@93
|
257 self.hiddenRegions[region] = true
|
Nenue@93
|
258 region:SetShown(false)
|
Nenue@93
|
259 hooksecurefunc(region)
|
Nenue@93
|
260 end
|
Nenue@93
|
261 end
|
Nenue@84
|
262
|
Nenue@90
|
263 function VeneerBuffFrameMixin:SetupButton (name)
|
Nenue@68
|
264 local frame = _G[name ]
|
Nenue@84
|
265 if self.DetectedFrames[frame] then
|
Nenue@86
|
266 --print('|cFFFF4400Attempting to skin a frame that already went through.|r')
|
Nenue@68
|
267 return
|
Nenue@68
|
268 end
|
Nenue@86
|
269 --print('|cFFFFFF00Adopting', name)
|
Nenue@68
|
270
|
Nenue@68
|
271 local icon = _G[name .. 'Icon']
|
Nenue@68
|
272 local border = _G[name .. 'Border']
|
Nenue@68
|
273 local count = _G[name .. 'Count']
|
Nenue@68
|
274 local duration = _G[name .. 'Duration']
|
Nenue@84
|
275 local veneer = self:Acquire(frame)
|
Nenue@84
|
276 local offset = BUFF_BUTTON_ZOOM/2
|
Nenue@68
|
277
|
Nenue@84
|
278 self.DetectedFrames[frame] = frame
|
Nenue@68
|
279 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
|
Nenue@84
|
280 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset)
|
Nenue@68
|
281
|
Nenue@78
|
282
|
Nenue@86
|
283
|
Nenue@84
|
284 DoRegionHooks(veneer, border)
|
Nenue@68
|
285 if border then
|
Nenue@68
|
286 local color = DebuffTypeColor["none"]
|
Nenue@68
|
287 if aurasCache[frame] and aurasCache[frame][5] then
|
Nenue@68
|
288 color = DebuffTypeColor[aurasCache[frame][5]]
|
Nenue@68
|
289 end
|
Nenue@71
|
290 veneer.progress.fg:SetColorTexture(color.r,color.g,color.b)
|
Nenue@75
|
291 veneer.border:SetColorTexture(0,0,0,1)
|
Nenue@79
|
292 veneer.border:Show()
|
Nenue@79
|
293 else
|
Nenue@79
|
294 veneer.border:SetColorTexture(0,0,0,1)
|
Nenue@79
|
295 veneer.border:Show()
|
Nenue@68
|
296 end
|
Nenue@68
|
297
|
Nenue@93
|
298 if count then
|
Nenue@86
|
299 count:ClearAllPoints()
|
Nenue@93
|
300 hooksecurefunc(count, 'Show', function(self) self:Hide() end)
|
Nenue@93
|
301 if count:GetText() then
|
Nenue@93
|
302 veneer.count:SetText(count:GetText())
|
Nenue@93
|
303 end
|
Nenue@86
|
304 end
|
Nenue@86
|
305 if duration then
|
Nenue@86
|
306 duration:ClearAllPoints()
|
Nenue@86
|
307 end
|
Nenue@86
|
308
|
Nenue@86
|
309
|
Nenue@86
|
310
|
Nenue@68
|
311
|
Nenue@68
|
312 hooksecurefunc(frame, "Hide", function(self)
|
Nenue@68
|
313 local isVisible = self:IsVisible()
|
Nenue@68
|
314 if isVisible ~= visibility[self] then
|
Nenue@68
|
315 visibility[self] = isVisible
|
Nenue@68
|
316 end
|
Nenue@68
|
317 veneer:Hide()
|
Nenue@73
|
318 veneer.underlay:Hide()
|
Nenue@68
|
319 end)
|
Nenue@68
|
320
|
Nenue@68
|
321 hooksecurefunc(frame, 'Show', function(self)
|
Nenue@68
|
322 veneer:Show()
|
Nenue@68
|
323 local isVisible = self:IsVisible()
|
Nenue@68
|
324 if isVisible ~= visibility[self] then
|
Nenue@68
|
325 print('|cFFFFFF00SHOW|r', self:GetName())
|
Nenue@68
|
326 visibility[self] = isVisible
|
Nenue@68
|
327 end
|
Nenue@74
|
328 veneer.underlay:Show()
|
Nenue@68
|
329 end)
|
Nenue@68
|
330
|
Nenue@68
|
331 end
|
Nenue@68
|
332
|
Nenue@68
|
333
|
Nenue@61
|
334 --- Set widgets to reflect the passed parameters
|
Nenue@90
|
335 function VeneerBuffFrameMixin:UpdateButton (frame, duration, expires)
|
Nenue@84
|
336 local veneer = self:Acquire(frame)
|
Nenue@68
|
337 -- is it a new button?
|
Nenue@84
|
338 if not self.DetectedFrames[frame] then
|
Nenue@84
|
339 self:SetupButton(frame:GetName())
|
Nenue@68
|
340 end
|
Nenue@68
|
341
|
Nenue@86
|
342 --[[
|
Nenue@86
|
343 if frame.count then
|
Nenue@86
|
344 frame.count:SetText('test')
|
Nenue@86
|
345 frame.count:Show()
|
Nenue@86
|
346 end
|
Nenue@86
|
347 --]]
|
Nenue@86
|
348 local name, rank, icon, count, _, duration, expires = UnitAura(frame.unit, frame:GetID(), frame.filter)
|
Nenue@86
|
349
|
Nenue@59
|
350
|
Nenue@61
|
351 if expires and duration then
|
Nenue@61
|
352 if duration ~= 0 then
|
Nenue@61
|
353 local startTime = (expires - duration)
|
Nenue@61
|
354 local endTime = expires or 0
|
Nenue@61
|
355 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires)
|
Nenue@61
|
356 veneer.progress:Show()
|
Nenue@61
|
357 veneer.elapsed = 0
|
Nenue@61
|
358 veneer.progress:SetScript('OnUpdate', function(self, elapsed)
|
Nenue@61
|
359 veneer.elapsed = veneer.elapsed + elapsed
|
Nenue@60
|
360
|
Nenue@67
|
361 local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2)
|
Nenue@61
|
362 local t = GetTime()
|
Nenue@61
|
363 local progress = (t - startTime) / duration
|
Nenue@61
|
364
|
Nenue@67
|
365 local nw = (w - (w * progress))
|
Nenue@61
|
366 if veneer.elapsed >= 0.25 then
|
Nenue@61
|
367
|
Nenue@93
|
368 --tprint(t, startTime, floor(progress*100), w * progress, nw, w)
|
Nenue@61
|
369 veneer.elapsed = 0.25 - veneer.elapsed
|
Nenue@61
|
370 end
|
Nenue@61
|
371 if (progress >= 1) or not frame:IsVisible() then
|
Nenue@61
|
372 veneer.startTime = nil
|
Nenue@61
|
373 self:Hide()
|
Nenue@61
|
374 self:SetScript('OnUpdate', nil)
|
Nenue@61
|
375 else
|
Nenue@61
|
376 self.fg:SetWidth(nw)
|
Nenue@61
|
377 end
|
Nenue@61
|
378 end)
|
Nenue@61
|
379
|
Nenue@61
|
380 veneer.cooldown:Show()
|
Nenue@61
|
381 veneer.cooldown:SetCooldown(startTime, duration)
|
Nenue@61
|
382 else
|
Nenue@61
|
383 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero')
|
Nenue@61
|
384 veneer.progress:SetScript('OnUpdate', nil)
|
Nenue@61
|
385 veneer.progress:Hide()
|
Nenue@61
|
386 veneer.cooldown:Hide()
|
Nenue@61
|
387 end
|
Nenue@86
|
388
|
Nenue@90
|
389 if count and count > 1 then
|
Nenue@86
|
390 veneer.count:SetText(count)
|
Nenue@86
|
391 veneer.count:Show()
|
Nenue@90
|
392 frame.count:ClearAllPoints()
|
Nenue@86
|
393 else
|
Nenue@86
|
394 veneer.count:Hide()
|
Nenue@86
|
395 end
|
Nenue@86
|
396
|
Nenue@86
|
397
|
Nenue@61
|
398 else
|
Nenue@61
|
399 veneer.progress:Hide()
|
Nenue@61
|
400 veneer.cooldown:SetCooldown(0,0)
|
Nenue@61
|
401 veneer.cooldown:Hide()
|
Nenue@61
|
402 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration')
|
Nenue@59
|
403 end
|
Nenue@59
|
404 veneer:Show()
|
Nenue@59
|
405 end
|
Nenue@59
|
406
|
Nenue@59
|
407
|
Nenue@59
|
408 --- Provides the number of changed indices for use in deciding between partial and full veneer updates
|
Nenue@90
|
409 function VeneerBuffFrameMixin:ButtonHasChanged (frame, ...)
|
Nenue@59
|
410 aurasCache[frame] = aurasCache[frame] or {}
|
Nenue@59
|
411 local hasChange = 0
|
Nenue@59
|
412 local numVals = select('#',...)
|
Nenue@59
|
413 for i = 1, numVals do
|
Nenue@59
|
414 local arg = select(i, ...)
|
Nenue@59
|
415 if aurasCache[frame][i] ~= arg then
|
Nenue@59
|
416 hasChange = hasChange + 1
|
Nenue@59
|
417 end
|
Nenue@59
|
418 aurasCache[frame][i] = arg
|
Nenue@59
|
419 end
|
Nenue@59
|
420 return hasChange
|
Nenue@59
|
421 end
|
Nenue@59
|
422
|
Nenue@90
|
423 function VeneerBuffFrameMixin:OnAuraButton_Update (name, index, filter)
|
Nenue@59
|
424 local bName = name..index
|
Nenue@59
|
425 local frame = _G[bName]
|
Nenue@59
|
426 if frame and frame:IsVisible() then
|
Nenue@61
|
427 -- if the name or expirationTime changed
|
Nenue@86
|
428
|
Nenue@61
|
429 if not skinnedFrames[frame] then
|
Nenue@61
|
430 tinsert(pendingFrames, frame)
|
Nenue@61
|
431 end
|
Nenue@59
|
432 expirationCache[name] = frame.expirationTime
|
Nenue@86
|
433 self:UpdateButton(frame)
|
Nenue@68
|
434
|
Nenue@59
|
435
|
Nenue@59
|
436 end
|
Nenue@59
|
437 end
|
Nenue@59
|
438
|
Nenue@90
|
439 function VeneerBuffFrameMixin:OnUpdateAllBuffAnchors ()
|
Nenue@59
|
440 local todo = {}
|
Nenue@59
|
441 if #pendingFrames >= 1 then
|
Nenue@59
|
442
|
Nenue@59
|
443 print('|cFFBBFF00AllBuffAnchors|r', #pendingFrames)
|
Nenue@59
|
444 while pendingFrames[1] do
|
Nenue@59
|
445 local frame = tremove(pendingFrames)
|
Nenue@59
|
446 tinsert(todo, frame:GetName())
|
Nenue@59
|
447
|
Nenue@61
|
448 -- re-apply custom anchors
|
Nenue@59
|
449 end
|
Nenue@68
|
450 print(tconcat(todo, ', '))
|
Nenue@59
|
451 end
|
Nenue@59
|
452 --BuffButton1
|
Nenue@59
|
453 --DebuffButton1
|
Nenue@61
|
454 --todo: separate frame groups and iterate over them at appropriate times
|
Nenue@60
|
455 if BuffButton1 then
|
Nenue@78
|
456
|
Nenue@68
|
457 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0)
|
Nenue@60
|
458 end
|
Nenue@60
|
459
|
Nenue@70
|
460 local lastBuff, topBuff
|
Nenue@74
|
461 local numBuffs = 0
|
Nenue@90
|
462 local numColumns = 1
|
Nenue@90
|
463 local maxColumn = 1
|
Nenue@70
|
464 for i = 1, BUFF_ACTUAL_DISPLAY do
|
Nenue@70
|
465 local buff = _G['BuffButton'..i]
|
Nenue@70
|
466 if buff then
|
Nenue@74
|
467 numBuffs = numBuffs + 1
|
Nenue@74
|
468 buff:ClearAllPoints()
|
Nenue@75
|
469 if mod(numBuffs,BUFFS_PER_ROW) == 1 then
|
Nenue@74
|
470 if numBuffs == 1 then
|
Nenue@80
|
471 buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
|
Nenue@90
|
472 plugin.currentTop = buff
|
Nenue@71
|
473 else
|
Nenue@71
|
474 buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@71
|
475 end
|
Nenue@90
|
476 numColumns = 1
|
Nenue@70
|
477 topBuff = buff
|
Nenue@70
|
478 else
|
Nenue@71
|
479 buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@90
|
480 numColumns = numColumns + 1
|
Nenue@90
|
481 end
|
Nenue@90
|
482 if numColumns > maxColumn then
|
Nenue@90
|
483 maxColumn = numColumns
|
Nenue@90
|
484 plugin.currentLeft = buff
|
Nenue@70
|
485 end
|
Nenue@70
|
486 lastBuff = buff
|
Nenue@70
|
487 end
|
Nenue@70
|
488 end
|
Nenue@70
|
489
|
Nenue@74
|
490 numBuffs = 0
|
Nenue@70
|
491 for i = 1, DEBUFF_ACTUAL_DISPLAY do
|
Nenue@70
|
492 local debuff = _G['DebuffButton'..i]
|
Nenue@70
|
493 if debuff then
|
Nenue@74
|
494 numBuffs = numBuffs + 1
|
Nenue@93
|
495 if mod(numBuffs, BUFFS_PER_ROW) == 1 then
|
Nenue@93
|
496
|
Nenue@93
|
497 if topBuff then
|
Nenue@93
|
498 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@93
|
499 else
|
Nenue@93
|
500 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
|
Nenue@93
|
501 end
|
Nenue@93
|
502 topBuff = debuff
|
Nenue@93
|
503
|
Nenue@70
|
504 else
|
Nenue@71
|
505 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@70
|
506 end
|
Nenue@70
|
507 lastBuff = debuff
|
Nenue@70
|
508 end
|
Nenue@70
|
509 end
|
Nenue@70
|
510
|
Nenue@74
|
511 if lastBuff then
|
Nenue@90
|
512 plugin.currentBottom = lastBuff
|
Nenue@74
|
513 end
|
Nenue@90
|
514
|
Nenue@90
|
515 self.Background:ClearAllPoints()
|
Nenue@90
|
516 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4)
|
Nenue@90
|
517 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4)
|
Nenue@90
|
518 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0)
|
Nenue@59
|
519 end
|
Nenue@90
|
520 function VeneerBuffFrameMixin:UpdateConfigLayers (configMode)
|
Nenue@90
|
521 self:SetShown(configMode)
|
Nenue@93
|
522 for _, button in pairs(self.Buttons) do
|
Nenue@93
|
523 button:SetShown(configMode)
|
Nenue@93
|
524 end
|
Nenue@90
|
525 end
|
Nenue@90
|
526 function VeneerBuffFrameMixin:OnUpdateDuration (frame, timeLeft)
|
Nenue@84
|
527 local veneer = self:Acquire(frame)
|
Nenue@60
|
528 local hours = floor(timeLeft/3600)
|
Nenue@60
|
529 local minutes = floor(mod(timeLeft, 3600)/60)
|
Nenue@60
|
530 local seconds = floor(mod(timeLeft, 60))
|
Nenue@60
|
531 local timeString = '%ds'
|
Nenue@59
|
532 if timeLeft > 3600 then
|
Nenue@60
|
533 timeString = format('%d:%02d', hours, minutes)
|
Nenue@60
|
534 elseif timeLeft > 60 then
|
Nenue@60
|
535 timeString = format('%d:%02d', minutes, seconds)
|
Nenue@61
|
536 else
|
Nenue@60
|
537 timeString = format('%d', seconds)
|
Nenue@59
|
538 end
|
Nenue@59
|
539
|
Nenue@74
|
540 if timeLeft < 10 then
|
Nenue@74
|
541 if not veneer.duration.getHuge then
|
Nenue@74
|
542 veneer.duration.getHuge = true
|
Nenue@74
|
543 veneer.duration:SetFontObject(VeneerNumberFontLarge)
|
Nenue@75
|
544 veneer.duration:SetTextColor(1,1,0,1)
|
Nenue@74
|
545 end
|
Nenue@74
|
546 else
|
Nenue@74
|
547 if veneer.duration.getHuge then
|
Nenue@74
|
548 veneer.duration.getHuge = nil
|
Nenue@74
|
549 veneer.duration:SetFontObject(VeneerNumberFont)
|
Nenue@74
|
550 veneer.duration:SetTextColor(1,1,1,1)
|
Nenue@74
|
551 end
|
Nenue@74
|
552 end
|
Nenue@74
|
553
|
Nenue@69
|
554 veneer.duration:SetText(timeString)
|
Nenue@59
|
555 end
|
Nenue@59
|
556
|
Nenue@59
|
557
|
Nenue@59
|
558 -- Obtains the first instance of Tenchant use
|
Nenue@59
|
559
|
Nenue@90
|
560 function VeneerBuffFrameMixin:OnTemporaryEnchantFrameUpdate (...)
|
Nenue@59
|
561 local numVals = select('#', ...)
|
Nenue@59
|
562 local numItems = numVals / 4
|
Nenue@59
|
563 if numItems >= 1 then
|
Nenue@59
|
564 for itemIndex = numItems, 1, -1 do
|
Nenue@59
|
565 local frame = _G['TempEnchant'..itemIndex]
|
Nenue@59
|
566 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...)
|
Nenue@59
|
567
|
Nenue@59
|
568
|
Nenue@59
|
569 if hasEnchant then
|
Nenue@59
|
570 local endTime = floor(GetTime()*1000) + timeRemaining
|
Nenue@59
|
571
|
Nenue@59
|
572
|
Nenue@59
|
573 --print(endTime)
|
Nenue@59
|
574 if endTime ~= expirationCache[frame] then
|
Nenue@59
|
575 if expirationCache[frame] then
|
Nenue@59
|
576 print(endTime, expirationCache[frame], endTime - expirationCache[frame])
|
Nenue@59
|
577 end
|
Nenue@59
|
578 expirationCache[frame] = endTime
|
Nenue@59
|
579 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000))
|
Nenue@59
|
580 UpdateVeneer(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000))
|
Nenue@59
|
581 end
|
Nenue@59
|
582 else
|
Nenue@84
|
583 self:Acquire(frame):Hide()
|
Nenue@59
|
584 end
|
Nenue@59
|
585
|
Nenue@59
|
586 end
|
Nenue@59
|
587
|
Nenue@59
|
588 end
|
Nenue@59
|
589
|
Nenue@59
|
590 end
|
Nenue@90
|
591 function VeneerBuffFrameMixin:OnBuffFrameUpdate ()
|
Nenue@59
|
592 end
|
Nenue@59
|
593
|
Nenue@59
|
594
|
Nenue@90
|
595 function VeneerBuffFrameButtonMixin:OnLoad()
|
Nenue@90
|
596
|
Nenue@90
|
597 self.duration = self.progress.duration
|
Nenue@90
|
598 self.count = self.overlay.count
|
Nenue@90
|
599 self.border = self.underlay.bg
|
Nenue@90
|
600
|
Nenue@90
|
601 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {}
|
Nenue@90
|
602 self.configIndex = #VeneerBuffFrame.ConfigLayers
|
Nenue@90
|
603 for i, region in ipairs(self.ConfigLayers) do
|
Nenue@90
|
604 tinsert(VeneerBuffFrame.ConfigLayers, region)
|
Nenue@90
|
605 end
|
Nenue@90
|
606
|
Nenue@90
|
607 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers
|
Nenue@90
|
608 end
|
Nenue@90
|
609
|
Nenue@84
|
610 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
|
Nenue@59
|
611
|