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