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