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